Search code examples
javascriptjquerylistchildren

Remove the li childeren


I want remove the li that is arround this link.

I have this script.

$('a[href$="archief"]').children('li').remove();

What do i wrong? I want to select the list item that is arround the link.


Solution

  • Wrong way, children() searches for children, closest(), parent() and parents() looks for parents :

    $('a[href$="archief"]').closest('li').remove();
    

    This would of course also remove anything inside the list item.