代码位于@ http://www.iluvtrees.org/我们正在尝试删除冒号 (:)...
jQuery('#events-calendar-list li a').text(this.text().replace(':', ''));
我正在远程执行此操作,并且能够使用此脚本获得更简单的字符串来工作。选择器的困难,我们的 html 看起来像这样......
...
<ul id="events-calendar-list">
<li id="events-calendar-list-630" title="
<strong>Title: </strong><b>#62 It's Little Things
</b><br />Check your fuel consumption and tire pressure to make sure your car is running as efficiently as possible.
<br /><strong>Start Time: </strong>12:00 am<br /><strong>End Time: </strong>12:00 am<br />">events=Object { mouseover=[1]}handle=function()
<a href="http://www.iluvtrees.org/">
<strong style="display: none;">Thu 3/14/2013</strong>
: //<- - - this is what we are trying to remove - - - -
<b>#62 It's Little Things</b>
<br>
</a>
...
我目前无权访问 PHP 文件以从那里删除。
最佳答案
您可以简单地删除 anchor 内的文本节点:
$('a').contents().filter(function(node) {
return this.nodeType === 3; // filter text nodes
}).remove();
关于php - 为什么这个 jQuery Replace() 不能在 <a 标签中工作,尽管我让它在 <p 标签中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15424208/