<html>  
<head>  
    <script src="jquery-1.3.2.js"></script>  
    <script src="listtolist.js"></script>  
           <script >
                                   $('document').ready(function(){
                                                   $('#clickMe').click(function(){
                                                                   alert($('#a').val()==0);
                                                           })
                                           
                                           });
                   </script>
</head>  
<body>  
                        <input type="button" value="clickMe" id="clickMe">
                        <input type="hidden" value="" id="a">  
</body>  
</html>  alert出啥?

解决方案 »

  1.   


    <!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=utf-8" />
    <title>test</title>
    <script src="jquery-1.3.2.js"></script>
    <script>
    $('document').ready(function(){
      $('#clickMe').click(function(){
    alert($('#a').val()=="")//true
    alert($('#a').val()==null)//false
       alert($('#a').val()==0);//true
      })
    });
    </script>
    </head><body>
    <input type="button" value="clickMe" id="clickMe">
      <input type="hidden" value="" id="a">  
    </body>
    </html>
    因为val没有值,所以js默认的处理为""活着0
      

  2.   

    alert($('#a').val()==0);$('#1').val()返回空字符串==运算符会把两边的值 转换为bool类型
    ""和0转换为bool都是false,所以返回true请使用===
    alert($('#a').val()===0);