I would like to add "check all" and "uncheck all" button to this script. My js coding skills isnt too good and any help would be highly appricated.

See working example jsfiddle here: [http://jsfiddle.net/Efz72/38/]

有帮助吗?

解决方案

Sounds like you want to add a button that calls the following jQuery function:

function checkAllCheckboxes(){
   $('input:checkbox').attr('checked', true) 
}

The HTML code for the button should look something like:

 <input type="button" value="Check All" onclick="checkAllCheckboxes();" />

Two notes: 1. The <input> tags in your code does not have a closing bracket ( /> ) 2. You want the checkAllCheckboxes function above to be defined as 'No wrap - in <head>' in JSFiddle for this to work properly there.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top