Your ckname are name 1 name 2 name 3 name 4 name 5 name 6 Select / Unselect All <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script language="javascript"> function selectallCHBox(){ if($('#selectall').attr('checked')){ var inputs = document.getElementsByClassName('chechid'); var checkboxes = []; for (var i = 0; i < inputs.length; i++) { if (inputs[i].type == 'checkbox') { inputs[i].checked =true; } } } else { var inputs = document.getElementsByClassName('chechid'); var checkboxes = []; for (var i = 0; i < inputs.length; i++) { if (inputs[i].type == 'checkbox') { inputs[i].checked =false; } } } } </script> </head> <body> <form name="form1" onSubmit="return validate()"> Your ckname are <br> <input type="checkbox...
Show Hide div using jquery click here for show div show hide div jquery example Hi , I am Rajeev Dhar Dwivedi <script> function showdiv(){ $("#mydiv").show(); } function hidediv(){ $("#mydiv").hide() } </script> <div id="mydiv" style="display:none; background-color:#FF66CC; width:300px ; height:40px" > <b> Hi , I am Rajeev Dhar Dwivedi </b> </div> <input type="button" onclick="showdiv()" value="Show Div" /> <input type="button" onclick="hidediv()" value="Hide Div" />
how to know checkbox is checked in javascript, Here we are provide a example similar to that Select Check box code for this example : <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script> function selectcheckbox(x){ var cls = $(x).attr('class'); if($('.'+cls).attr('checked')){ alert('chek box is checked'); } else { alert('check box is unchecked');} } </script> <form action="" method=""> <input type="checkbox" name="checkboxname" value="checkboxvalue" class="checkboxcls" onclick="selectcheckbox(this)"/> Select Check box </form>
focu() function is use in javascript for focus of input box when you enter any wrong values in inputbox for example email , mobile number .. etc example : Email Id : when you enter wrong email them your cursor blink on input box code : in javascript document.getElementById('email').focus(); in jquery $('#email').focus() ; where email s id of input box