简体   繁体   English

如何从包含在文本中的星号中删除星号(*) <td> 使用jQuery?

[英]How do I remove an asterisk (*) from a the text contained with a <td> using jquery?

I've got a table column definition that looks like this: 我有一个表列定义,如下所示:

<td class="dvRequiredField validationFailed">
    *&nbsp;
    <input name="ctl00$MainContent$dvCustomer$ctl04" type="text" title="First Name" class="validationFailed">
    &nbsp;Required Field.
</td>

How do remove the "asterisk" (or in a sense replace it with '') using jquery? 如何使用jquery删除“星号”(或在某种意义上将其替换为“”)?

I've tried the following: 我尝试了以下方法:

$('td.validationFailed').each(function () {
    $(this)[0].innerHTML = $(this)[0].innerHTML.replace(/\*/g, '');
});

It does not work. 这是行不通的。 It replaces/removes the text value of my input control. 它替换/删除了我输入控件的文本值。

Thanks, JohnB 谢谢,JohnB

DEMO DEMO

$('td.validationFailed').contents().filter(function() { 
    return this.nodeType == 3 && this.wholeText.indexOf('*') > -1; 
})
.remove();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM