What I'm trying to do:
Take a nav item - when it's clicked, add a "<" out to the side of it. Then when something different is clicked, I'd like to remove the "<" that I just added, so the newly selected item is the only item with the "<" next to it.
Simplified code:
$('.sidebar a').click( function() {
//-->here I need to clear it off of any other items which have it
$(this).after(' <');
});
(Incidentally, I recognize that I could do something with css, but that won't work in this instance. Needs to b开发者_如何学Ce js.)
Here's the code
$('.sidebar a').click( function() {
//Remove if there are any currently on the page
$("#remove_later").remove();
//Add to the link user just clicked onto
$(this).after('<span id="remove_later"> <</span>');
});
Here's the jsfiddle link http://jsfiddle.net/MHhp4/
what about
$('.sidebar a').click( function() {
//-->here I need to clear it off of any other items which have it
$(this).after('<span id="remove_later"> <</span>');
});
and remove it with
$("#remove_later").remove();
?
精彩评论