Fetch previous and next element with a certain condition
Lets start with a sample source:
- <hr>
- <p>....foobar...</p>
- <hr>
Now I want to delete all <hr> elements which are immediately
a) BEFORE a <p> element which contain "foobar"
b) AFTER a <p> element which contain "foobar"
If I code for example
$("p:contains('foobar')").prev().remove();
then elements might be delete which are NOT a <hr> element
So how can I specify otherwise the delete statement of a sequence of elements with one condition?
Peter