YUI等於下面的JavaScript代碼是什麼?YUI相當於removeAttribute()JavaScript方法
document.getElementById("myDiv").removeAttribute("id");
YUI等於下面的JavaScript代碼是什麼?YUI相當於removeAttribute()JavaScript方法
document.getElementById("myDiv").removeAttribute("id");
我猜你的意思YUI2。但如果你的意思YUI3,這是完全一樣的DOM方法:
Y.one('#myDiv').removeAttribute('someAttribute');
您可以在API文檔閱讀所有Y.Node方法列表:http://yuilibrary.com/yui/docs/api/classes/Node.html
YUI2沒有這一項,但如下:
http://developer.yahoo.com/yui/docs/YAHOO.util.Dom.html#method_getAttribute http://developer.yahoo.com/yui/docs/YAHOO.util.Dom.html#method_setAttribute
編輯:你爲什麼不喜歡removeAttribute?它已經跨瀏覽器完全支持:HTTP://www.quirksmode.org/dom/w3c_core.html#t118
YAHOO.util.Dom.get("myDiv").removeAttribute("id");
YUI沒有方法的removeAttribute –