[英]How do I remove (only) an asterisk from the inner text of an HTML <td> component?
[英]How do I remove an asterisk (*) from a the text contained with a <td> using jquery?
我有一个表列定义,如下所示:
<td class="dvRequiredField validationFailed">
*
<input name="ctl00$MainContent$dvCustomer$ctl04" type="text" title="First Name" class="validationFailed">
Required Field.
</td>
如何使用jquery删除“星号”(或在某种意义上将其替换为“”)?
我尝试了以下方法:
$('td.validationFailed').each(function () {
$(this)[0].innerHTML = $(this)[0].innerHTML.replace(/\*/g, '');
});
这是行不通的。 它替换/删除了我输入控件的文本值。
谢谢,JohnB
$('td.validationFailed').contents().filter(function() {
return this.nodeType == 3 && this.wholeText.indexOf('*') > -1;
})
.remove();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.