1

Can anyone help me to find all the "/" and remove them with jQuery please? HTML below:

<ul id="list">
  <li>a /</li>
  <li>b /</li>
  <li>c</li>
</ul>
1
  • 1
    jquery can't find text, just elements. You'll have to instead find elements that have said text, then use javascript string manipulation to do the work. Commented Oct 28, 2013 at 22:10

1 Answer 1

4

Try using :contains() to find each item, and then looping through to remove the /:

$("li:contains('/')").each(function(){
    $(this).text($(this).text().replace(' /',''));
});

You'll need to modify for variances, but based on the HTML shown this will do the trick.

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

Comments

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.