jQuery how to remove all <span> tags from a <div>?

两盒软妹~` 提交于 2019-12-06 18:27:56

问题


I've tried both of the following but none of them worked:

$('#divhtml').remove('span')

$('#divhtml').find('span').remove()

EDIT: $('#divhtml').find('span').remove() worked on 2nd try.


回答1:


You have already used a correct statement:

$('#divhtml').find('span').remove()

This should work. Please provide more context... See this jsfiddle as "proof" that something else is wrong: http://jsfiddle.net/Pbgqy/




回答2:


Try this:

$("#divhtml span").remove()


来源:https://stackoverflow.com/questions/8931955/jquery-how-to-remove-all-span-tags-from-a-div

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!