HTML 代码:
<img src="test1.jpg"/> <img src="test2.jpg"/>jQuery 代码:
$("img").size(); 结果:
2 这个2是怎么输出来的?就是怎么写js输出2?谢了

解决方案 »

  1.   

    alert($("img").size());document.write($("img").size());
    2种输出,不清楚LZ想要哪一种
      

  2.   

    document.getElementsByTagName("img").length
      

  3.   

    function(){var i=1;}()与var i=1;是一样的·
      

  4.   

    <head runat="server">
        <title>无标题页</title>
        <script type="text/javascript" language="javascript">
        
         document.write($("img").size()); 
         
        </script>
    </head>
    <body>
        <form id="form1" >
        <img src="test1.jpg"/> <img src="test2.jpg"/> 
        </form>
    </body>
    </html>怎么没有输出?
      

  5.   

      function window_onload(){
         document.write($("img").size()); 
         }
         
        </script>
    </head>
    <body  onload="window_onload()">
    也没用...为什么?
      

  6.   

    第一,jQuery的js你都没有引入
    第二,执行JS的时候页面还没有加载完,你是取不到IMG控件的
      

  7.   

      function window_onload(){ 
        document.write($("img").size()); 
        } 
        
        </script> 
    </head> 
    <body  onload="window_onload()"> jQuery的js怎么引入 
    能不能给写个完整的这个例子..多谢
      

  8.   

    jequry1.2.6
    <!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 type="text/javascript" src="../js/jquery-1.2.6.js"></script>
    </head><body></body>
    </html>