This article mainly introduces how to use shift + click to select and reverse select checkbox in javascript. It involves javascript's judgment on keyboard buttons and checkbox operation skills, for more information about how to select and invert checkbox Using shift + click in javascript, see the example in this article. Share it with you for your reference. The specific implementation method is as follows:
Var lastChecked = null; var handleChecked = function (e) {if (lastChecked & e. shiftKey) {var I = $ ('input [type = "checkbox"] '). index (lastChecked); var j = $ ('input [type = "checkbox" comment 'character .index(e.tar get); var checkboxes = []; if (j> I) {checkboxes = $ ('input [type = "checkbox"]: gt ('+ (I-1) +'): lt ('+ (j-I) + ') ');} else {checkboxes =$ ('input [type = "checkbox"]: gt (' + j + '): lt (' + (I-j) + ');} if (! Certificate (e.tar get ). is (': checked') {$ (checkboxes ). removeAttr ('checked');} else {$ (checkboxes ). attr ('checked', 'checked') ;}} lastChecked = e.tar get; // Other click action code .} $ ('input [type = checkbox] '). click (handleChecked );
I hope this article will help you design javascript programs.