I’m trying to remove all hyperlinks from the selected li with jquery but doesn’t seems to work properly. When is clicked all my hyperlinks getting removed. A detaliet view of my code http://jsfiddle.net/78kAu/1/. The event what is firing the code looks as it follows
$('a').click(function(){
var selected = $(this).attr('class');
var row = $('.elements li').length;
alert(selected);
$("a").remove();
});
Instead of
you want:
What you’ve got says “find all the
<a>elements on the page, and remove each of them.”If you want to remove all the
<a>elements from some container above the clicked element, like an<li>, you’d do this: