Q:

Change a CSS class using jQuery

0

Change a CSS class using jQuery.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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%;
}
JavaScript Code:
$(document).ready(function(){ 
  $('#button1').click(function(){   $('#pid').removeClass('center').addClass('large');       
   });
});

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now