Thursday, 30 June 2011

Toggle all selection of checkboxes in a div Through JQuery


//JavaScript, JQuery code
function Toggle_Checked(status, divId)
{
    try
    {
        $('#' + divId).find(':checkbox').attr('checked', status);
    }
    catch(err){}
}


//HTML code
<input type='checkbox' onclick=”Toggle_Checked(this.checked,’are_list_div’)”>
<div id=’are_list_div’>
<input type='checkbox' id=’1’> India
<input type='checkbox' id=’2’> Sri Lanka
<input type='checkbox' id=’3’> Nepal
</div>

No comments:

Post a Comment