简体   繁体   中英

Jquery Remove the details inside tag

Hi I'm currently using jQuery $('#status').remove(); to remove the detail of my

<p id="status"DETAILS!!!!></p> But what I need is just to remove the data inside of my tag not the tag itself. Is there any script or way to do it?

Actually, to remove inner HTML with jQuery is as simple as:

$("#status").empty();

Check out this link for more info: https://api.jquery.com/empty/

$("#status").empty();

这可能是您的解决方案,因为$("selector").remove()会删除与所选标签关联的所有元素,而$("selector").empty()会删除所选标签内的所有元素。

You could use $('#status').text(''); to clear the text inside your tag

you could try

If your div looks like this:

<div id="status">content in here</div>


status = document.getElementById("#status")

status.innerHTML = '';

It will make it look like this:

<div id="status"></div>

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM