jQuery map method
home
Run
screen_rotation
fullscreen
cloud_download
<!DOCTYPE html> <html> <head> <title>jQuery Demo example</title> <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"> </script> <script type="text/javascript"> $(document).ready(function(){ $( "#selectAll" ).on( "click", function(event) { $( "input" ).map(function(){ $(this).attr("checked","checked"); }); }); $( "#unselectAll" ).on( "click", function(event) { $( "input" ).map(function(){ $(this).removeAttr("checked"); }); }); }); </script> </head> <body> <div> <p><input type="checkbox" value="1" name="sel[]">Select 1</p> <p><input type="checkbox" value="2" name="sel[]">Select 2</p> <p><input type="checkbox" value="3" name="sel[]">Select 3</p> <p><input type="checkbox" value="4" name="sel[]">Select 4</p> <h4><a href="javascript:void(0);" id="selectAll">Click Me to select all </a></h4> <h4><a href="javascript:void(0);" id="unselectAll">Click Me to unselect all </a></h4> </div> </body> </html>
<!DOCTYPE html> <html> <head> <title>jQuery Demo example</title> <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"> </script> <script type="text/javascript"> $(document).ready(function(){ $( "#selectAll" ).on( "click", function(event) { $( "input" ).map(function(){ $(this).attr("checked","checked"); }); }); $( "#unselectAll" ).on( "click", function(event) { $( "input" ).map(function(){ $(this).removeAttr("checked"); }); }); }); </script> </head> <body> <div> <p><input type="checkbox" value="1" name="sel[]">Select 1</p> <p><input type="checkbox" value="2" name="sel[]">Select 2</p> <p><input type="checkbox" value="3" name="sel[]">Select 3</p> <p><input type="checkbox" value="4" name="sel[]">Select 4</p> <h4><a href="javascript:void(0);" id="selectAll">Click Me to select all </a></h4> <h4><a href="javascript:void(0);" id="unselectAll">Click Me to unselect all </a></h4> </div> </body> </html>
Copyrights@tutorialsplane.com