[英]Two Remove asterisk sign via Jquery from a label
In a paragraph I have a label that has two asterisk (*) signs. 在一段中,我有一个带有两个星号(*)的标签。 On page Load I want to check if it has two asterisk (**) signs then I want to remove one of them
在“加载”页面上,我想检查它是否有两个星号(**),然后我要删除其中一个
My HTML looks like: 我的HTML看起来像:
<p>
<label for="xyz">**Required</label>
</p>
How is it done via jquery? 如何通过jquery完成?
Use text()
method with callback to iterate and use String#replace
method to update the text. 使用带有回调的
text()
方法进行迭代,并使用String#replace
方法更新文本。
// get all label which contains 2 adjuscent * $('label:contains("**")').text(function(i, txt) { // iterate over them, replace and update return txt.replace('**', '*'); })
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <p> <label for="xyz">**Required</label> </p>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.