我是 JQuery 的新手,真的很苦恼如何执行我想要的查询。
我正在使用 SharePoint,当使用外部数据列并将其设置为必填字段时,错误消息始终出现,直到您填写数据。与其他类型的列不同,它们仅在您单击“确定/保存”后才会出现,而不是填写数据。因此,我需要从这些类型的列中删除错误消息文本。
我假设我需要在包含单词“外部数据”的 .ms-error 类中搜索跨度并将其隐藏。
通过使用 IE 开发人员工具栏,我确定了该区域。
<table class="ms-usereditor" id="ctl00_m_g_05df537a_596b_443a_a11e_764069facec8_ctl00_Field_External_539c53fe_8334_43c8_b089_cc28d7895e68_Picker_OuterTable" style="border-collapse: collapse;" border="0" cellSpacing="0" cellPadding="0">
<tbody>
<tr>
<td colSpan="3">
<span class="ms-error" id="ctl00_m_g_05df537a_596b_443a_a11e_764069facec8_ctl00_Field_External_539c53fe_8334_43c8_b089_cc28d7895e68_Picker_errorLabel">
Text - You must specify a value before using the Check button. You can also use Select button to choose External Data.
</span>
</td>
</tr>
</tbody>
</table>
有人可以帮助我使用 JQuery。
最佳答案
var spans = $('.ms-error');
spans.text(''); // clear the text
spans.hide(); // make them display: none
spans.remove(); // remove them from the DOM completely
spans.empty(); // remove all their content
关于javascript - Jquery 从 span 中删除文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11207432/