js在ie下不支持getAttribute("class"),不应该呀。
<html>
<HEAD>
<TITLE> New Document </TITLE>
<SCRIPT LANGUAGE= "JavaScript ">
<!--
function test(obj){
alert(obj.getAttribute( "class "));
alert(obj.getAttribute( "name "));
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<input type=button name= 'name ' class= "check " onclick= "test(this); " value= "click me ">
</BODY>
</HTML>
======
FF下可以得到class的值check ,IE下居然不可以。
这个getAttribute不是dom方法吗?应该支持IE的。我看javasciprt编程艺术里学习用的。
------解决方案--------------------className
<html>
<HEAD>
<TITLE> New Document </TITLE>
<SCRIPT LANGUAGE= "JavaScript ">
<!--
function test(obj){
alert(obj.getAttribute( "className "));
alert(obj.getAttribute( "name "));
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<input type=button name= 'name ' class= "check " onclick= "test(this); " value= "click me ">
</BODY>
</HTML>
------解决方案--------------------class是标签本身的属性,不需要用getAttribute
CLASS Attribute | className Property Internet Development Index
--------------------------------------------
Sets or retrieves the class of the object.
Syntax
HTML <ELEMENT CLASS = sClass... >
Scripting object.className [ = sClass ]