3 回答
$('#grape1,#grape12').find('br').remove();
$('br', '#grape1, #grape12').remove();
The second argument in the $
selector allows you to filter your search to a given subset, instead of the entire DOM. In this case we tell jQuery to only look inside the grape1
and grape12
divs. This will match all br's in those div's.
If that doesn't work (as happened in my case also) it's probably because the <br>
are generated by some scripts after the JS .remove()
code execution.
To check if I was right I set a quite long timeout and all my unwanted <br>
disappeared after that time.
So, in the end I just decided to put a simple CSS
#grape1 br, #grape12 br {
display: none;
}
and eveybody's happy =)