Change a CSS class using jQuery.
HTML Code :
<!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-git.js"></script> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>Change a CSS class name using jQuery.</title> </head> <body> <p id="pid" class="center"> jQuery Exercises</p> <input id="button1" type="button" value="Click to change the Class" /> </body> </html>
CSS Code:
p.center { text-align: center; color: red; } p.large { font-size: 200%; }
$(document).ready(function(){ $('#button1').click(function(){ $('#pid').removeClass('center').addClass('large'); }); });
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
HTML Code :
CSS Code: