how can I remove the following text 'search:' with JqLite or original javascript?
<label>
search:<input type="text">
<label>
update
I didn't explain the question very clearly. All the HTML elements are created by angular directive I can only manipulate DOM with JQLITE or JS maybe. And also attributes of input may change so I can't replace all the child nodes of label with a new input
Please try this
<html>
<body onload="remove()">
<label>
search:
<input type="text" id="search">
</label>
</body>
<script type="text/javascript">
function remove() {
document.getElementById('search').remove();
}
</script>
</html>
label.innerHtml='<input type="text">'
其中label是该标签标记周围的查询包装
Here's what you need to do.Given that your HTML is like this:
<label>
search:<input type="text">
<label>
You need to first get a hold of the label.You do this with
$("label")
Considering you want to manipulate the text inside, you get $("label").innerHTML.Let's put this in a variable.
x=$("label").innerHTML;
Then, we use the replace string function to replace the value of "search:" with a blank space.
y=x.replace("search:","");
We finally push back this value of y to the inner HTML by
$("label").innerHTML=y
You can shorten this into much fewer steps, but I separated them for ease of understanding.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.