Use the jQuery addClass() method to add a new class or change a class using the jQuery library.
How to add a class on a button click in jquery?
The syntax of addClass() method -
$("id of div").addClass("new_class");
Use id of a div block and addClass() method to change div class.
If you want to add a new class on the button click -
script type="text/javascript">
$(document).ready(function() {
$( "#my_btn" ).click(function() {
$("#my_div_id").addClass('class_two');
});
});
</script>
HTML button and div like that -
<div class="class_one" id="my_div_id">Add new class</div>
<button class="btn" id="my_btn">Click Me</button>
Create two classes class_one and class_two in the stylesheet.