ff下弹出undefined
在firebug里面看 div里面确实有了个menu的属性,但是却还是弹出undefined,这是为什么了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title> </title> </head> 
<body> 
<div id='ss'> </div> 
<input value="aaa" type="button" onclick="show()"/>
<script language="javascript">
var div =null;
window.onload = function(){
div = document.getElementById('ss');
div.setAttribute("menu",'aaa');
}function show(){
alert(div.menu)
}
</script>
</body> 
</html> 

解决方案 »

  1.   


    alert(div.getAttribute('menu'))
      

  2.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <title> </title> </head> 
    <body> 
    <div id='ss'> </div> 
    <input value="aaa" type="button" onclick="show()"/>
    <script language="javascript">
    var div =null;
    window.onload = function(){
        div = document.getElementById('ss');
        div.setAttribute("menu",'aaa');
        //div.menu = 'aaa';
    }function show(){
        alert(div.getAttribute('menu'))
    }
    </script>
    </body> 
    </html>
      

  3.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <title> </title> </head> 
    <body> 
    <div id='ss'> </div> 
    <input value="aaa" type="button" onclick="show()"/>
    <script language="javascript">
    var div =null; div = document.getElementById('ss');
     div.setAttribute("menu",'aaa');
    function show(){
        alert(div.getAttribute('menu'));
    }
    </script>
    </body> 
    </html>