Search code examples
jqueryjquery-selectorsdom-traversal

finding a li with specific title and removing the rest li


I have a list in which i need to select an element (according to title attr of <a> inside <li>) on page load and remove rest of list elements except the selected one.

Using this:

$("#div").find("a[title='Previous Page']").not(this).remove();

Its not working.

http://jsfiddle.net/ymhrF/16/


Solution

  • $("#custom_pagination").find("a").not('[title="umm"]').parent('li').remove();
    

    If you wanted to keep it as a single line of code.