Yesterday morning I wrote how to use Jquery to achieve full selection.
According to your comments, I have modified some of the difficult-to-write aspects of the program, and I am still at a limited level. There are various issues that cannot be considered.
At the end of the article, I raised a question. I had to write a general method to call it, so now I had this article. When I got home at night, I wrote the results.
The following example can be used for discussion and study. If you think it is good, you can directly apply it to the project.
1: Why write this method?
There are a lot of questions about selecting all one sentence on the Internet, but it seems that a problem is ignored. The fully selected checkbox can control the following subcheckbox, however, the following sub-checkbox should also be able to control all the above options, so that I can use this method.
2: Development Process: to achieve general purpose, we need to solve two problems: how to group, how to determine which checkbox in the group is all selected, I thought, I think it is okay to use name grouping,
Use class to determine whether the checkbox group needs to be fully selected. First, find all the classes that need to be fully selected, and then find the name attribute. Based on the name attribute, you can find other subcheckboxes. You only need to find the elements and perform operations.
3::Checkboxall selected. Zip
4: file. below is my implemented js, saved as xs_checkbox_all.js
xsChk = ; xsChkAll = + xsChk + ; name = $().attr(= + xsChk + + name + ; $(, $()[]. xschk = $( IAll = $(name).length; IChk = $(name + ).length; isAllChecked = ; (IAll !==
Page usage
<! DOCTYPE html PUBLIC>
The results can be achieved. If you have any optimizations, please advise. I will do better. Thank you.