This article mainly introduces jQuery's implementation of multiple input Summation Methods, involving jQuery's skills in getting the element values of input forms and operations, for more information about how to implement multiple input summation of jQuery, see the example in this article. Share it with you for your reference. The specific implementation method is as follows:
The html page code is as follows:
Some jQuery code is as follows:
Script $ ("input [id ^ = 'add']"). change (function () {var sum = 0; $ ("input [id ^ = 'add']"). each (function () {var r =/^ -? \ D + $/; // positive integer if ($ (this). val ()! = ''&&! R. test ($ (this ). val () {$ (this ). val (""); // The regular expression is not null} else if ($ (this ). val ()! = '') {Sum + = parseInt ($ (this ). val ();} document. getElementById ("add "). value = sum;}) ;}); scriptBecause the input attribute is readonly, when you press Backspace in the browser to delete the input value, the page will return a response. For solutions, refer to the previous article JQuery implementation of methods to prevent return of the return Space key.
I hope this article will help you with jQuery programming.