i have found the below code which adds a class of Blue when a it has a specific class of Select, however it is applying it to the whole menu. I wish to apply it on click when it has the class of Select. I wish to apply an effect to the li before so that i can apply and :after and :before style.
This is the original code:-
<script>
$(document).ready(function() {
if ($('#headerContent ul li a').hasClass('select')) {
$('#headerContent ul li a').addClass('Blue');
}
});
</script>
This is my rewrite which appears to not work.
<script>
$(document).ready(function() {
if ($('#headerContent ul li a').hasClass('select')).onClick(function() {
$('#headerContent ul li').addClass('Blue');})
});
</script>
EDIT:
This i feel is not a duplicate! Maybe i should have explained it more. Im using this in conjunction with a jquery plugin for scrolling which adds the class select when clicked! I am using this plugin Smooth scrolling, which adds a class of select to the anchor tag.
I have put a jsfiddle together:
http://jsfiddle.net/axajLjb1/1/
I have updated my fiddle. Basically as you can see it applies a class on click when it has select, however it is not removing it when i click another option.