<html>
<head>
<script>
window.onload = function(){
var code = document.getElementById("code");
alert(code.value);
alert(typeof code.value);
}
</script>
</head>
<body>
<textarea id="code" rows=15 cols=50></textarea>
</boyd>
</html>
为什么value为空 type 为string 呀

解决方案 »

  1.   

    因为
    <html>
    <head>
    <script>
    window.onload = function(){
    var code = document.getElementById("code");
    alert(code.value==“”);
    alert(typeof “”);
    alert(typeof code.value);
    }
    </script>
    </head>
    <body>
    <textarea id="code" rows=15 cols=50></textarea>
    </boyd>
    </html>
      

  2.   


    <html>
    <head>
    <script>
    window.onload = function(){
    var code = document.getElementById("code");
    //alert(code.value==“”);
    //alert(typeof “”);
    //alert(typeof code.value);
    if(code.value !=""){
    alert("a");
    }else{
    alert("b")
    }
    }
    </script>
    </head>
    <body>
    <textarea id="code" rows=15 cols=50></textarea>
    </boyd>
    </html>我靠我见鬼了  如果这样没错的话弹出的应该是b没错吧
    但是为什么我的会弹出A来呢