从body的所有子元素中删除属性(Remove an attribute from all the children elements of body)
我正在使用bing的脚本。 好吧,当我运行它时,它会为所有元素分配一个属性“lang”并改变我自己的样式。 该脚本在线,所以我无法编辑它。 我能做的是使用jquery从所有元素中删除该属性,因此不会发生样式更改。 这是我搜索后到目前为止所尝试的内容。
$('body').children("*").removeAttr('lang'); $('body').find("*").removeAttr("lang");他们没有工作。 有什么建议吗?
i am using a script from bing. Well, when i run it, it assigns an attribute "lang" to all of the elements and changing my own styling. The script is online so i can't edit it. What i can do is remove that attribute from all the elements using jquery so no styling change would occur. This is what i have tried so far after searching through.
$('body').children("*").removeAttr('lang'); $('body').find("*").removeAttr("lang");They are not working. Any suggestion?
最满意答案
尝试这个
$('* [lang]').removeAttr('lang');DEMO
要么
$('[lang]').removeAttr('lang');DEMO
You can use Has Attribute Selector [name] and then use removeAttr()
Selects elements that have the specified attribute, with any value.
$('[lang]').removeAttr('lang'); console.log($('span').prop('outerHTML'))<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <span lang='en'>1</span>
更多推荐
发布评论