0
如何去除一些html元素而不裏面的內容(YUI2)YUI2-如何刪除一些沒有內容的html元素? ?
簡單的例子,除去span.exclass元件而不含量+插入空格用於保持詞語分離:
輸入:
<br/> <span class="just"></span>
<div>
textetxt <span class="exclass">texttetx</span>texttext
</div>
<br/>
<p> <span class="just"></span>
textetxt <span class="exclass">texttetx</span>texttext
</p>
輸出:
<br/> <span class="just"></span>
<div>
textetxt texttetx texttext
</div>
<br/>
<p> <span class="just"></span>
textetxt texttetx texttext
</p>
jQuery的應該是,如果我沒有錯 - 但是在yui2我不知道:
$('span.exclass').each(function(){
$(this).replaceWith($(this).text());
});
感謝, 優素福