jQuery Tutorial
$("p").addClass("css-class1 css-class2 css-class3 ..")
<html> <head> <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script> <script> $(document).ready(function() { $("p").addClass( "paragraph1" ); }); </script> <style> .paragraph1 { color: blue; background-color: lightgrey; font-size: 16px; } </style> </head> <body> <p>Welcome to jQuery learning!</p> </body> </html>Output:
Welcome to jQuery learning!
<html> <head> <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script> <script> $(document).ready(function() { $("p").addClass( "paragraph1 bolder" ); }); </script> <style> .paragraph1 { color: blue; background-color: lightgrey; font-size: 16px; } .bolder{ font-weight: bold; } </style> </head> <body> <p>Welcome to jQuery learning!</p> </body> </html>Output:
Welcome to jQuery learning!
<html> <head> <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script> <script> $(document).ready(function() { $( "p" ).addClass(function( index ) { return "paragraph" + index; }); }); </script> <style> .paragraph0 { color: blue; background-color: grey; font-size: 20px; } </style> </head> <body> <p>Welcome to jQuery learning!</p> <p>Welcome to jQuery lab!</p> </body> </html>Output:
Welcome to jQuery learning!
Welcome to jQuery lab!
$("p").removeClass("css-class1 css-class2 css-class3 ..")
<html> <head> <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script> <script> $(document).ready(function() { $("p").removeClass( "paragraph1" ); }); </script> <style> .paragraph1 { color: blue; background-color: lightgrey; font-size: 16px; } </style> </head> <body> <p class="paragraph1">Welcome to jQuery learning!</p> </body> </html>Output:
Welcome to jQuery learning!
<html> <head> <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script> <script> $(document).ready(function() { $("p").removeClass( "paragraph1 bolder" ); }); </script> <style> .paragraph1 { color: blue; background-color: lightgrey; font-size: 16px; } .bolder{ font-weight: bold; } </style> </head> <body> <p class="paragraph1 bolder">Welcome to jQuery learning!</p> </body> </html>Output:
Welcome to jQuery learning!
<html> <head> <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script> <script> $(document).ready(function() { $("p").removeClass( "paragraph1" ).addClass("bolder"); }); </script> <style> .paragraph1 { color: blue; background-color: lightgrey; font-size: 16px; } .bolder{ font-weight: bold; } </style> </head> <body> <p class="paragraph1">Welcome to jQuery learning!</p> </body> </html>Output:
Welcome to jQuery learning!
jQuery Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us
| Report website issues in Github
| Facebook page
| Google+ page