0

I have a working listview populated by js. I wanted to add an option to hide the listview but retain the listdivider. I can only come up with this:

$('#myList').empty()

and this emmpties everyrthing. How can I empty the list but not the listdivider?

many thanks.

1
  • 1
    what do you understand by listdivider ? give us some html code Commented Feb 16, 2012 at 11:00

1 Answer 1

1

Without seeing your HTML I'm assuming here, but try this:

$('#myList li').not("#divider").remove()

This will remove each li element contained in #myList, except the li with an id of divider.

You will need to put whatever valid selector will catch your dividing element in the not() method.

Sign up to request clarification or add additional context in comments.

1 Comment

It seems jQuery Mobile uses data-role='list-divider', so this should do it: $("#myList li").not("[data-role='list-divider']").remove().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.