Oliver Kuchies Oliver Kuchies - 4 years ago 149
HTML Question

Checkbox Check Event Listener

Recently I have been working with the Chrome Plugin API and I am looking to develop a plugin which will make life easier for me for managing a website.

Now what I wish to do is to fire an event when a certain checkbox is checked.
As this website does not belong to me I cannot change the code therefore I am using the Chrome API. One of the main problems is that rather than there being an ID, there is a Name. I was wondering if I could fire the function once the certain checkbox with the 'name' is checked.

Thanks

Answer Source

Try something like that:

$('input[name=somecheckboxyname]').change(function(){

    if($(this).is(':checked'))
    {
        // Checkbox is checked.
    }
    else
    {
        // Checkbox is not checked.
    }    

});
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download