I have the following code which shows nested ul and hides the other open ones on click. my question is how can i add a background image to the parent li a that opens the nested ul and removes the background image from the parent li a of the ones it closes?
here is my jquery:
$(document).ready(function() {
$('ul ul').hide();
$('ul li > a').click(function(event) {
$('ul ul').hide('slow');
$(this).parent().find('ul').show('slow');
});
});;
// will add the class
$('#item').addClass('myClass');
// will remove the class
$('#item').removeClass('myClass');
// will toggle the class (add it if doesn't have it or remove it if it does)
$('#item').toggleClass('myClass');
and inline styles;
// will override those properties
$('#item').css({'color':'red','background':'blue'});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With