object.setAttribute(sName, vValue [, iFlags])
sName參數應是Dom屬性而非html中的屬性。Dom中Html專有的接口屬性應該以小寫字母開頭,如果屬性有多個單詞構成,第二個單詞以及接下來的每個單詞的首字母都要大寫,如frameBorder。
另外說一下iflags參數:
iFlags Optional. Integer that specifies one the following flags:
0 When the attribute is set, it overwrites any attributes with the same name, regardless of their case.
1 Default. The case of the attribute that you set is respected when it is set on the object.
0:覆蓋任何同名屬性(忽略大小寫)
1:默認,覆蓋已經被設定的屬性值
上面的問題我也可以setAttribute(‘frameborder’ , '0' , 0)實現。
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。