How to select all checkboxes using JQuery

Posted 24 Aug 17 by Darren Welch

 

It's actually very simple...

 

We select the ID of the select all checkbox and use the .change() function.

 

$("#selectAll").change(function() {})

 

Within the change function we use a JQuery selector to find all checkboxes and the .prop function to set it's checked value to the same value as the selectall checkbox

 

$("input:checkbox").prop('checked', $(this).prop("checked"));

 

You can fiddle with the code here and test it out.

 





Darren Welch

By

Darren Welch


  24 Aug 17


Contact me online

 Facebook

 Twitter

 Linked In

 Git Hub

Related Content




Learn to code

05 Feb 2017




The Hill Garden and Pergola

29 Jun 2017




Send ctrl alt delete over remote desktop

05 Feb 2017