我有一个名为shop_attributes
jQuery和改变HTML输出
结构的表类如下:
<table class="shop_attributes">
<tbody>
<tr class="">
<th>Reserved</th>
<td>
<p>false</p>
</td>
</tr>
<tr class="alt">
<th>Show Terms And Conditions</th>
<td>
<p>true</p>
</td>
</tr>
</td>
</tr>
</tbody>
</table>
使用jQuery我想要的虚假每个实例更改为不和的每个实例是的。
我有下面的代码,那里还没有。任何人都可以在这里提出问题。
(function($) {
$(document).ready(function() {
if ($('#tab-additional_information > table > tbody > tr:nth-child(2) > td > p').val() == "true" {
$('#tab-additional_information > table > tbody > tr:nth-child(2) > td > p').replaceWith("Yes")
}
});
}(jQuery));
'p'标签不返回'VAL ()'。使用'text()'或'html()' –
另外,你的HTML是无效的,你的JavaScript中有拼写错误。 – j08691
为了与Quentin的答案一起提供一些建议,'val()'主要用于从表单元素(认为输入)获取值。你可以阅读它[这里](http://api.jquery.com/val/)。 –