删除 >通过使用 javascript/jquery 识别正确的文本节点从列表中
今天下午我问了一个有点类似的问题,然后意识到答案是我的问题不正确......
考虑到以下情况:
<p class="p">
<div> </div>
<div>
<a href="foo"> a </a> >
<a href="foo1"> b </a>
<a href="foo2"> c</a>
<a href="foo3"> b </a> >
<a href="foo4"> c </a>
</div>
</p>
我需要从页面中删除“>”`以及a标签在它之前。这是一个动态列表,因此它会随着时间的推移而不断增长。我需要有人抓住“>”删除它,然后删除它前面的 a 标签。
有什么建议吗?
I asked a somewhat similar question this afternoon and then realized as great as the answer is my question was not correct...
given the following:
<p class="p">
<div> </div>
<div>
<a href="foo"> a </a> >
<a href="foo1"> b </a>
<a href="foo2"> c</a>
<a href="foo3"> b </a> >
<a href="foo4"> c </a>
</div>
</p>
I need to remove the ">"` from the page as well as the a tag that precedes it. This is a dynamic list so it will continously grow over time. I need to someone latch onto the ">" remove it and then remove the a tag before it.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

您的标记无效。
元素将从
中踢出。
更正标记后,您可以执行以下操作:
JSFIDDLE DEMO
或者使用更多 jQuery:
JSFIDDLE DEMO
或者这个:
JSFIDDLE 演示
Your markup is invalid. The
<div>
elements are going to be kicked out of the<p>
.After correcting your markup, you could do this:
JSFIDDLE DEMO
Or with a little more jQuery:
JSFIDDLE DEMO
Or this:
JSFIDDLE DEMO