Category: jQuery Questions

How to Check All Checkboxes Using jQuery

To check all checkboxes in jQuery, we make use of prop() function with attribute value selector.  This function is only available in jQuery 1.6 or higher.  For jQuery 1.5 or lower, please make use of attr() function.  Example is given below for jQuery 1.6 or higher. <!DOCTYPE html> <html> <head> <title>jQuery Tutorial </title> <script src="http://code.jquery.com/jquery-latest.js"></script>

How to Uncheck a Checkbox Using jQuery

To uncheck a checkbox in jQuery, we make use of prop() function.  This function is only available in jQuery 1.6 or higher.  For jQuery 1.5 or lower, please make use of attr() function.  Example is given below for jQuery 1.6 or higher. <!DOCTYPE html> <html> <head> <title>jQuery Tutorial </title> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> //Function to

How to Check a Checkbox Using jQuery

To check a checkbox in jQuery, we make use of prop() function.  This function is only available in jQuery 1.6 or higher.  For jQuery 1.5 or lower, please make use of attr() function.  Example is given below for jQuery 1.6 or higher. <!DOCTYPE html> <html> <head> <title>jQuery Tutorial </title> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> //Function to

How to Change Image Src Attribute Value Using jQuery

To change image source attribute value using jQuery, we make use of attr() function.  Example is given below. <!DOCTYPE html> <html> <head> <title>jQuery Tutorial </title> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> //Function to Change Image. function ChangeImage(){ $('#myImage').attr('src', 'http://www.fwait.com/wp-content/uploads/2015/11/jquery-115x115.jpg'); } </script> </head> <body> <input type="button" value="Change Image" onclick="ChangeImage()"/> <br /> <br /> <img id="myImage" src="http://www.fwait.com/wp-content/uploads/2015/11/JavaScript-115x115.png" > </body>

How to Add Style Using jQuery

To add style using jQuery, we make use of css() function.  Example is given below. <!DOCTYPE html> <html> <head> <title>jQuery Tutorial </title> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> //Function to apply style. function myStyle(){ $('#divHello').css('background-color','red'); } </script> </head> <body> <input type="button" value="Apply CSS" onclick="myStyle()"/> <br /> <br /> <div id="divHello">Hello World! </div> </body> </html>