In this paper, we analyze the whole selection of checkbox based on jquery. Share to everyone for your reference, specific as follows:
The most recent development project encountered a very strange problem, that is, checkbox selection and selection of all
A framework for using jquery. has been the use of
Detects the selected checkbox
$ (' input[name= ' abc ']:checked '). each (function () {})
But when I found out that I needed a full selection, I used
$ (' input[name= "abc"]). attr (' checked ', true);
$ (' input[name= "abc"]). attr (' checked ', false);
, it works when it's first loaded, then clicks on it and only shows itself.
But when clicked, view the source code, attribute checked has been added to the
Baffled, the last search, the original is the Attr property for checked, he will not change the DOM style, will only change its property values, jquery provides a way to replace, the following can be
$ (' input[name= "abc"]). Prop (' checked ', true);
$ (' input[name= "abc"]). Prop (' checked ', false);
But then again, I couldn't detect which element was clicked when I was not fully selected, and then I made a fuss over name.
$ (' input[name= ' abc[]:checked '). Each (function (i) {});
or
$ (' input[name= ' abc[] '). Each (function (i) {
var flag = $ (this). Prop (' checked ');
if (flag) {
//$ (this) is the selected element
}
})
Solve the problem.
More interested readers of jquery-related content can view the site: "jquery form Operation Tips", "jquery switching effects and techniques summary", "jquery drag-and-drop effects and techniques summary", "JQuery Extended Skills Summary", " jquery Common Classic Effects Summary "jquery animation and special effects usage Summary", "jquery selector usage Summary" and "jquery common Plug-ins and Usage summary"
I hope this article will help you with the jquery program design.