Today, We want to share with you add active class onclick javascript.In this post we will show you toggle active class javascript, hear for javascript add active class to current page we will give you demo and example for implement.In this post, we will learn about Dynamically addClass CSS click using jQuery with an example.
How To Add Active Class To Current Element?
add / remove active class
HTML Code
CSS Code
li.active { color: green; }
Simple jQuery
var selector = '.nav li'; $(selector).on('click', function(){ $(selector).removeClass('active'); $(this).addClass('active'); });
Highlight the active/current (pressed) button:
index.html
Active Button
Highlight the active/current (pressed) button.
I hope you get an idea about add active class after page load jquery.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.