我有一个采用以下格式的td

<td>
    Business Owner - Delivery Director <br>
    <a href="mailto:[email protected]">[email protected]</a>
</td>


如何只用其他内容替换文本"Business Owner - Delivery Director"

使用this.text()获取Business Owner - Delivery Director[email protected],但是我只想要
Business Owner - Delivery Director.

最佳答案

使用.contents()获取文本节点(带有CharacterData interface),然后操纵其内容:

$("td").contents()[0].data = "Businees Owner (CEO)";


Demo at jsfiddle.net

关于javascript - 替换td内的部分文本,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13760664/

10-12 01:15