jQuery日本語リファレンス

jQuery does not mean Japanese Query...

ヌー

Utilities/API/jQuery - Sample Code

jQuery.each(object, callback)

 
<!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 = [ "one", "two", "three", "four", "five" ];
 var obj = { one:1, two:2, three:3, four:4, five:5 };
 jQuery.each(arr, function() {
 $("#" + this).text("My id is " + this + ".");
 return (this != "four"); // will stop running to skip "five"
 });
 jQuery.each(obj, function(i, val) {
 $("#" + i).append(document.createTextNode(" - " + val));
 });
 });
 </script>
 <style>
 div { color:blue; }
 div#five { color:red; }
 </style>
</head>
<body>
 <div id="one"></div>
 <div id="two"></div>
 <div id="three"></div>
 <div id="four"></div>
 <div id="five"></div>
</body>
</html>
 
 
[実行結果] [フレーム]
[jQuery.each(object, callback) の説明へ]
© Copyright 2009 by semooh.jp | Design by Free CSS Templates - Thanks to Dubai Apartments

AltStyle によって変換されたページ (->オリジナル) /