jQuery – Change Classes and Select Ids in JS

 

 

Here I will show how to change classes in jQuery and to use classes and ids. The idea of the sample is really simple – we have two divs – one clickable and the other one not. Once we click the clickable div, the other one changes its color.

How it is done? Simply with one click function and one if-else in jQuery. Initially we assign to the second div the class “show_div_red” and once we click on the first div, we change the class to a “show_div_green|, which has a green background. And it somehow works 🙂

light_change

Pretty much that is the whole story. The code comes here:

HTML

CSS:

JS:

If for any reason you would like to see it in GitHub, you may see it here!

 

Enjoy it 🙂

About

VBA Developer

Tagged with: , ,