I used 'tag'.innerHTML
.it will render with adding an endtag.How can i get only the display content inside a selected tag html?
<div id="tabs">
<ul class="tabs">
<li class="current"><a><span>News</span></a></li>
<li><a><span>Videos</span></a></li>
<li><a><span>Photos</span></a></li>
<li><a><span>Twitter</span></a></li>
</ul>
</div>
actually i need to get code like this by js between <pre>
tags
Look at this :
HTML :
<li><a><span><b>News</b></span></a></li>
jQuery :
var pureText = $("li").text();
var val = $("li").val();
var html = $("li").html();
你应该使用text()
代替,这将只返回文本
在纯JavaScript
您可以使用innerText
'tag'.innerText
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.