Script to find click event of checkbox

Once I was in situation when I have to call same function for all checkbox. I was wondering how to do it without writing code for every checkbox. Then I come across with a solution of using JQuery. I used JQuery to find click event of all checkbox on a form element. Below is the code snippet:


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" type="text/javascript"></script>
<script language="javascript">
$(document).ready(function(){
    $("form :checkbox").click(function(){
        alert('hi : ' +this.name);    
     }); 
});
</
script>

Really JQuery is more powerful than JavaScript. I have done it for checkbox, likewise we can find the events of other controls also. Enjoy have fun with JQuery.

Comments

Popular posts from this blog

Installation and Configuration of Office Online Server with SharePoint 2019

Workflow Manager 1.0- Installation, Configuration and Issues

SharePoint 2019 Upgrade Part 6: SharePoint Upgrade Issues