Checkbox using Jquery

Check boxes are often used in websites.They provide selection related assist in websites.So in this lesson we may see checkbox  changed events using jquery.We can find controls by using selectors such as ID selector,CLASS selector.

HTML
<input type='checkbox' name ='test' Id='check'  />

Jquery

$('input:checkbox[name=test]').change(function () 
{
                if ($(this).is(':checked')==true) 
{
                    alert('Checked');
                }
                else {
                    alert('Unchecked');
                }
                
   });


This will return the message "checked" when you select the checkbox and display "unchecked" when you deselect the checkbox.We can identify checkbox by its ID as well.

We can also call this checkbox by its I'd.
$('#check'). change (function (){
alert('Hello');
});



I hope it will be helpful for you.

Comments

Popular posts from this blog

Types of Architects

Basic measurements

Search html table contents based on its td using Jquery