hii,
Today i am sharing a blog on How to add and remove a class on click event in javascript.
First of all you need to either download few plugins or just copy and paste the below link inside head tag.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
</script>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
Note:The above mentioned link will be written inside head tag
Code for adding and removing class on click event:
<script type="text/javascript">
$(document).ready(function(){
$(".className").click(function(){
$(this).addClass("active");
$(this).removeClass("inactive");
});
});
</script>
Note:The above mentioned code can be either added in head tag or in body tag.
0 Comment(s)