[英]jQuery table replace partial table content inside html
I have this table: 我有这张桌子:
HTML 的HTML
<div class="BBclass1 BBclass2">
<table>
<tr>
<td><b>name:</b> value1</td>
<td>Value2</td>
<td>Value3</td>
<td>Value4</td>
</tr>
</table>
<div>
I need to replace 'name:'
to 'Hello:'
我需要将
'name:'
替换为 'Hello:'
How do I do this? 我该怎么做呢?
I have already tried 我已经尝试过
$("td :contains('name:')").text("Hello:");
For some reason it replaces the entire table with name1. 由于某种原因,它将整个表替换为name1。
this does not work either: 这也不起作用:
$("div:contains('name:')").html("Hello");
Any other suggestions? 还有其他建议吗?
You are using the wrong selector.
您
using the wrong selector.
There should be no space between 两者之间不应有空格
`"td :contains"`
^------- Remove this space
Supposed to be 应该是
$("td:contains('name:')").text("Hello:");
You can also try 您也可以尝试
$("td b:contains('name:')").text("Hello:");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.