I have a WordPress site where I have some "pipe" elements which I want to change color when clicked. I'm new to jQuery so I would need some help to do this. This is what I have so far (a very simplified version of it all):
jQuery:
jQuery(function() {
jQuery(".--clearGreen").click(function() {
jQuery(this).addClass("--clearGreenClicked");
});
});
CSS:
.--clearGreen {
background-color: rgba(255, 255, 255, 0);
border: 2px solid green;
}
.--clearGreenClicked {
background-color: blue;
border: 2px solid blue;
color: white;
}
This works to add the .--clearGreenClicked class to the clicked .--clearGreen "pipe" that I have on the page. What I would like to achieve is to make it so that only the clicked "pipe" gets the change applied to it and all the other "pipes" return to the original styling, so basically that they "switch" styles depending on what "pipe" is clicked. I've tried to use .not in combination with .has but I can't seem to get it to work properly. Thanks!