jQuery日本語リファレンス

jQuery does not mean Japanese Query...

Core/API/jQuery - Sample Code

size()


            
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="/jquery/js/jquery.js"></script>
  <script>
  window.onload = (function(){try{
    
    $(document.body).click(function () {
      $(document.body).append($("<div>"));
      var n = $("div").size();
      $("span").text("There are " + n + " divs." +
                     "Click to add more.");
    }).click(); // trigger the click to start
  }catch(e){}});</script>
  <style>
  body { cursor:pointer; }
  div { width:50px; height:30px; margin:5px; float:left;
        background:blue; }
  span { color:red; }
  </style>
<style>html,body{border:0; margin:0; padding:0;}</style></head>
<body>
  <span></span>
  <div></div>
</body>
</html>
            
          
[実行結果]
[size() の説明へ]