简体   繁体   English

.html('')在Safari中不起作用

[英].html('') doesn't work in safari

I am trying to remove an object with jquery using .html('') in my component. 我正在尝试在组件中使用.html('')使用jquery删除对象。 It's works in almost browsers, but in Safari doesn't work. 它几乎可以在浏览器中使用,但是在Safari中不起作用。 why this happen? 为什么会这样?

If you want to take an element out of the DOM, use remove() , don't use .html("") . 如果要从DOM中remove()元素,请使用remove() ,不要使用.html("")

If you want to make the element empty, use empty() . 如果要使元素为空,请使用empty()

Also, to answer your question, you probably have some bug in your code because .html('') works on my Safari, tested on this jsfiddle . 另外,为了回答您的问题,您的代码中可能存在一些错误,因为.html('')可在我的Safari上运行,并在此jsfiddle上进行了测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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