我想清除“普通文本”,但不包括glyphicon的内容。
重要的代码部分及其结果:
$("#btn_test").html()
将给我:"<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span> Speichern & schließen"
$("#btn_test").text()
将给我:" Speichern & schließen"
我只想删除文本“ Speichern & schließen
”,而不使用.replace(...)
函数(因为文本是动态的)。
我尝试了$("#btn_test").text("")
,但这也会清除我的元素。
谢谢。
更新('possible duplicate'): 是的,这与此处相同的问题,但不是Chris Davis的答案,那个解决了我的问题。
span
元素之前或之后。 - 99999