[英]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.