jQuery日本語リファレンス

jQuery does not mean Japanese Query...

Utilities/API/jQuery - Sample Code

jQuery.inArray(value, array)


            
<!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>
  $(document).ready(function(){
    
    var arr = [ 4, "Pete", 8, "Pete", "John" ];

    $("span:eq(0)").text(jQuery.inArray("John", arr));
    $("span:eq(1)").text(jQuery.inArray(4, arr));
    $("span:eq(2)").text(jQuery.inArray("Pete", arr));
    $("span:eq(3)").text(jQuery.inArray("David", arr));

  });
  </script>
  <style>
  div { color:blue; }
  span { color:red; }
  </style>
</head>
<body>
  <div>"John" found at <span></span></div>
  <div>4 found at <span></span></div>
  <div>"Pete" found at <span></span></div>
  <div>"David" found at <span></span></div>
</body>
</html>
            
          
[実行結果]
[jQuery.inArray(value, array) の説明へ]