【发布时间】:2018-02-02 11:55:57
【问题描述】:
我有 警告标志 字符,它在 HTML 实体(十进制)中具有 ⚠ 的值,我正在尝试从所有复选框的标签文本中删除它。
例如,在 HTML 中,我的输入标签之一如下:
如何使用 $ (JQuery) 选择器从这些标签中删除 ⚠ html 实体。
这是我的尝试:
$('input:checkbox').each(function (index) {
// I thought by splitting that part and then joining it
// with an empty string would work.
$(this).next().text().split('⚠').join('');
});
<input id='input1'/><label for='input1'>This is the warning sign &#9888;</label>
【问题讨论】:
-
我在您的示例中看到并输入了没有 type="checkbox" 的内容。
-
你也得到了字符串,分割它,加入它,然后什么都不做。该字段的 text() 不会自动更新为该新值。如果要更新,必须将其重新设置。
标签: jquery html checkbox label html-entities