开发者

removeAttribute do not return true or false

开发者 https://www.devze.com 2022-12-31 02:44 出处:网络
I am 开发者_C百科tryingto remove attributes of aDOM element using below statement in javascript.

I am 开发者_C百科trying to remove attributes of a DOM element using below statement in javascript.

var res = nodes.removeAttribute("style");

but the res is always "undefined" it seems that the removeAttribute function does not return anything (I tested it on firefox browser)

How can I identify that the attribute is successfully removed or not ?

Thanks, Sourabh


nodes? It seems that you have an array of nodes. Anyway, removeAttribute will not return anything. To check if the attribute has been removed, use hasAttribute afterwards.

node.removeAttribute('foo');
if (node.hasAttribute('foo')) {
  // failed, foo still exists.
}


nodes.removeAttribute("style");

var isTheLanguageWorkingLikeItShouldAndThisCheckIsTotallyPointless = nodes.getAttribute("style");

0

精彩评论

暂无评论...
验证码 换一张
取 消