So I got the following html:
<ul>
<li><a href="#">test</a></li>
/
<li><a href="#">test</a></li>
/
<li><a href="#">test</a></li>
/
<li><a href="#">test</a></li>
<ul>
Sadly this is generated by a Plone extension which was forked and I don't have the possibility to change the output. The list will have a different amount of elements on different pages.
All I need to do is remove the slashed between the list elements. I couldn't come up with a good solution till now.
Is there a simple an powerful solution to do this with Javascript or jQuery?
Use .contents() and .filter() to filter out all the next nodes (nodeType == 3) then remove them using .remove()
$('ul').contents().filter(function(){
return this.nodeType == 3
}).remove()
Demo: Fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With