javascript:[].forEach.call(document.querySelectorAll('input[type="checkbox"]'),function(el){el.checked=true});
*** Will not work for older versions of (Internet Explorer) IE
(1) document.querySelectorAll not available untile IE v8
(2) forEach not available until IE v9
The use of a JavaScript toolkit/framework, e.g., JQuery, relieves the developer from having to worry about incompatibility issues like the ones mentioned above.
Verify that your browser didn't automatically remove the "javascript:" from its address bar, assuming you copy/pasted the javascript. If so, then just hand-type javascript: at the beginning and press your enter key.
Test it out here:
Alice
Bob
Cindy
JQuery Set all Checkboxes Version
If the page already has JQuery loaded, then you have less to type...
javascript:$(":checkbox").prop("checked", true);
That's because this page is not using (and has not loaded) the JQuery library.
So, to dynamically load JQuery on a page, e.g., this blog page, paste the following in the address bar:
javascript:(function () {
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js';
document.getElementsByTagName('body')[0].appendChild(s);
})();$(":checkbox").prop("checked", true);
readings were really very good. I will bookmark this blog so that I could often visit this blog often to read the latest article from your blog. I wait for your arrival at our website ...
ReplyDeletethanks, ...
By : ios development jakarta | firzil.co.id
ReplyDeleteI also agree with you ..... very useful information for us ...... keep it up thanks for this..........
Application Development
how to select only one or 2 of the 3 above checklist using this trick?
ReplyDeleteVinay,
ReplyDeleteTo check the 2nd and 3rd checkboxes, I'd do something like this:
$(":checkbox").filter(function(i) {
return $.inArray(i, [1, 2]) > -1;
}).prop("checked", true);
Thank you for the question,