PageRenderTime 44ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/1.3/docs/html/api/seed/kissy/each.html

https://github.com/yiminghe/kissyteam.github.com
HTML | 283 lines | 233 code | 31 blank | 19 comment | 0 complexity | 21605408d9fd963f4ca0819f1701bd8b MD5 | raw file
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <meta name="data-spm" content="1" data-spm-protocol="i" />
  6. <title>each &mdash; KISSY v1.3 Documentation</title>
  7. <link rel="stylesheet" href="http://g.tbcdn.cn/kissy/k/1.3.2/css/dpl/base-min.css"/>
  8. <link rel="stylesheet" href="../../../_static/kissy.css"/>
  9. <link rel="stylesheet" href="http://a.tbcdn.cn/s/kissy/gallery/sphinx/1.1.3/pygments.css" type="text/css" />
  10. <link rel="shortcut icon" href="http://a.tbcdn.cn/s/kissy/favicon.ico" type="image/x-icon" />
  11. <!--<link href='http://fonts.googleapis.com/css?family=Philosopher' rel='stylesheet' type='text/css'>-->
  12. <script>
  13. var DOCUMENTATION_OPTIONS = {
  14. URL_ROOT: '../../../',
  15. VERSION: '',
  16. COLLAPSE_INDEX: false,
  17. FILE_SUFFIX: '.html',
  18. HAS_SOURCE: true
  19. };
  20. </script>
  21. <script type="text/javascript" src="http://a.tbcdn.cn/s/kissy/gallery/sphinx/1.1.3/??jquery.js,underscore.js,doctools.js,searchtools.js"></script>
  22. <script>
  23. var _gaq = _gaq || [];
  24. _gaq.push(['_setAccount', 'UA-31470541-1']);
  25. _gaq.push(['_trackPageview']);
  26. (function() {
  27. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  28. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  29. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  30. })();
  31. </script>
  32. </head>
  33. <body><div id="header">
  34. <h1 class="logo"><a alt="KISSY" href="http://docs.kissyui.com">
  35. <img src="http://a.tbcdn.cn/s/kissy/logo.png" />
  36. </a></h1>
  37. <ul class="navigation">
  38. <li><a href="http://docs.kissyui.com">首页</a></li>
  39. <li><a href="../../../../html/tutorials/index.html" >Tutorials</a></li>
  40. <li><a href="../../../../html/api/index.html" >API</a></li>
  41. <li><a href="../../../../html/demo/index.html" >DEMO</a></li>
  42. <li><a href="https://groups.google.com/group/kissy-ui" >Google Group</a></li>
  43. <li><a href="http://www.github.com/kissyteam" >Source Code</a></li>
  44. <li><a href="http://docs.kissyui.com/1.3/api/" >English API Docs</a></li>
  45. <li><a href="http://blog.kissyui.com/" target="_blank">Offical Blog</a></li>
  46. </ul>
  47. <div id="searchbox" class="searchbox">
  48. <form class="search" action="../../../search.html" method="get">
  49. <input type="text" name="q" size="28" class="ipt"/>
  50. <input type="submit" value="Go" class="btn"/>
  51. <input type="hidden" name="check_keywords" value="yes"/>
  52. <input type="hidden" name="area" value="default"/>
  53. </form>
  54. </div>
  55. </div>
  56. <div id="content">
  57. <div id="layout" class="layout grid-s6m0e7">
  58. <div class="col-main">
  59. <div class="main-wrap">
  60. <div class='related'>
  61. <h3>Navigation</h3>
  62. <ul>
  63. <li class="right" style="margin-right: 10px">
  64. <a href="../../../genindex.html" title="General Index"
  65. accesskey="I">index</a></li>
  66. <li class="right" >
  67. <a href="../../../py-modindex.html" title="Python Module Index"
  68. >modules</a> | </li>
  69. <li class="right" >
  70. <a href="endsWith.html" title="endsWith"
  71. accesskey="N">next</a> | </li>
  72. <li class="right" >
  73. <a href="clone.html" title="clone"
  74. accesskey="P">previous</a> | </li>
  75. <li><a href="../../../index.html">KISSY v1.3 Documentation</a> &#187; </li>
  76. <li><a href="../../index.html" >API Documentation</a> &#187; </li>
  77. <li><a href="../index.html" >Seed</a> &#187; </li>
  78. <li><a href="index.html" accesskey="U">lang</a> &#187; </li>
  79. </ul>
  80. </div>
  81. <div class="body">
  82. <div class="section" id="each">
  83. <h1>each<a class="headerlink" href="#each" title="Permalink to this headline"></a></h1>
  84. <div class="section" id="methods">
  85. <h2>Methods<a class="headerlink" href="#methods" title="Permalink to this headline"></a></h2>
  86. <dl class="function">
  87. <dt id="seed.KISSY.each">
  88. <tt class="descclassname">KISSY.</tt><tt class="descname">each</tt><big>(</big><big>)</big><a class="headerlink" href="#seed.KISSY.each" title="Permalink to this definition"></a></dt>
  89. <dd><div class="line-block">
  90. <div class="line">Object <strong>KISSY.each</strong> ( o, fn[, context] )</div>
  91. <div class="line">遍历数组中的每一项, 执行指定方法.</div>
  92. </div>
  93. <table class="docutils field-list" frame="void" rules="none">
  94. <col class="field-name" />
  95. <col class="field-body" />
  96. <tbody valign="top">
  97. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  98. <li><strong>o</strong> (<em>Array|object</em>) &#8211; 需要遍历的数组或对象</li>
  99. <li><strong>fn</strong> (<em>function</em>) &#8211; <p>执行时, 接收 3 个参数</p>
  100. <ul>
  101. <li> o 为数组时, 参数为当前数组单项值, 当前 index, 数组 o</li>
  102. <li> o 为对象时, 参数为当前值 (value), 当前键 (key), 对象 o</li>
  103. </ul>
  104. </li>
  105. <li><strong>context</strong> (<em>object</em>) &#8211; fn 的上下文对象, 不指定为全局 window</li>
  106. </ul>
  107. </td>
  108. </tr>
  109. </tbody>
  110. </table>
  111. <p>例如</p>
  112. <div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">S</span> <span class="o">=</span> <span class="nx">KISSY</span><span class="p">,</span>
  113. <span class="nx">arr</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">],</span>
  114. <span class="nx">obj</span> <span class="o">=</span> <span class="p">{</span>
  115. <span class="s1">&#39;hi&#39;</span><span class="o">:</span> <span class="s1">&#39;kissy&#39;</span><span class="p">,</span>
  116. <span class="s1">&#39;bye&#39;</span><span class="o">:</span> <span class="s1">&#39;world&#39;</span>
  117. <span class="p">},</span>
  118. <span class="nx">sum</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
  119. <span class="nx">S</span><span class="p">.</span><span class="nx">each</span><span class="p">(</span><span class="nx">arr</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">item</span><span class="p">)</span> <span class="p">{</span>
  120. <span class="nx">sum</span> <span class="o">+=</span> <span class="nx">item</span><span class="p">;</span>
  121. <span class="p">});</span>
  122. <span class="nx">S</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">sum</span><span class="p">);</span> <span class="c1">// =&gt; 15</span>
  123. <span class="nx">S</span><span class="p">.</span><span class="nx">each</span><span class="p">(</span><span class="nx">obj</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">v</span><span class="p">,</span><span class="nx">k</span><span class="p">)</span> <span class="p">{</span>
  124. <span class="nx">S</span><span class="p">.</span><span class="nx">log</span><span class="p">([</span><span class="nx">v</span><span class="p">,</span><span class="nx">k</span><span class="p">]);</span>
  125. <span class="p">});</span>
  126. </pre></div>
  127. </div>
  128. </dd></dl>
  129. </div>
  130. </div>
  131. </div>
  132. <div class='related'>
  133. <h3>Navigation</h3>
  134. <ul>
  135. <li class="right" style="margin-right: 10px">
  136. <a href="../../../genindex.html" title="General Index"
  137. accesskey="I">index</a></li>
  138. <li class="right" >
  139. <a href="../../../py-modindex.html" title="Python Module Index"
  140. >modules</a> | </li>
  141. <li class="right" >
  142. <a href="endsWith.html" title="endsWith"
  143. accesskey="N">next</a> | </li>
  144. <li class="right" >
  145. <a href="clone.html" title="clone"
  146. accesskey="P">previous</a> | </li>
  147. <li><a href="../../../index.html">KISSY v1.3 Documentation</a> &#187; </li>
  148. <li><a href="../../index.html" >API Documentation</a> &#187; </li>
  149. <li><a href="../index.html" >Seed</a> &#187; </li>
  150. <li><a href="index.html" accesskey="U">lang</a> &#187; </li>
  151. </ul>
  152. </div>
  153. <div id="disqus_thread"></div>
  154. <script>
  155. if((window.location.hostname.indexOf("kissyui.com")!=-1 )&& window.localStorage.getItem("kissy-commment")!="0"){
  156. /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
  157. var disqus_shortname = 'kissy-docs'; // required: replace example with your forum shortname
  158. // The following are highly recommended additional parameters. Remove the slashes in front to use.
  159. //var disqus_identifier = '/anim';
  160. //var disqus_url = window.location;
  161. /* * * DON'T EDIT BELOW THIS LINE * * */
  162. (function() {
  163. var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
  164. dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
  165. (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  166. })();
  167. }
  168. </script>
  169. <!--<div id="google-search-box">
  170. <div id="cse" style="width: 100%;">Loading</div>
  171. <script>
  172. if(window.location.hostname.indexOf("kissyui.com")!=-1){
  173. document.write('<script src="http://www.google.com/jsapi" type="text/javascript"><'+'/script>');
  174. }
  175. </script>
  176. <script>
  177. if(window.location.hostname.indexOf("kissyui.com")!=-1){
  178. google.load('search', '1', {language : 'zh-CN', style : google.loader.themes.MINIMALIST});
  179. google.setOnLoadCallback(function() {
  180. var customSearchControl = new google.search.CustomSearchControl('012347804910294994683:n4uzb24gqdm');
  181. customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
  182. customSearchControl.draw('cse');
  183. }, true);
  184. }
  185. </script>
  186. </div>-->
  187. </div>
  188. </div>
  189. <div class="col-sub"><ul class="s-box api-toctree">
  190. <h2 class="s-box-hd">Seed</h2>
  191. <ul class="s-box-bd">
  192. <li><a href="index.html">lang</a></li>
  193. <li><a href="../loader/index.html">loader</a></li>
  194. </ul>
  195. </ul>
  196. <ul class="s-box core-toctree">
  197. <h2 class="s-box-hd">Core</h2>
  198. <ul class="s-box-bd">
  199. <li><a href="../../core/ajax/index.html">ajax</a></li>
  200. <li><a href="../../core/anim/index.html">anim</a></li>
  201. <li><a href="../../core/base/index.html">base</a></li>
  202. <li><a href="../../core/cookie/index.html">cookie</a></li>
  203. <li><a href="../../core/dom/index.html">dom</a></li>
  204. <li><a href="../../core/event/index.html">event</a></li>
  205. <li><a href="../../core/json/index.html">json</a></li>
  206. <li><a href="../../core/node/index.html">node</a></li>
  207. <li><a href="../../core/ua/index.html">ua</a></li>
  208. </ul>
  209. </ul>
  210. <ul class="s-box component-toctree">
  211. <h2 class="s-box-hd">Component</h2>
  212. <ul class="s-box-bd">
  213. <li><a href="../../component/button/index.html">button</a></li>
  214. <li><a href="../../component/calendar/index.html">calendar</a></li>
  215. <li><a href="../../component/color/index.html">color</a></li>
  216. <li><a href="../../component/combobox/index.html">combobox</a></li>
  217. <li><a href="../../component/component/index.html">component</a></li>
  218. <li><a href="../../component/datalazyload/index.html">datalazyload</a></li>
  219. <li><a href="../../component/dd/index.html">dd</a></li>
  220. <li><a href="../../component/editor/index.html">editor</a></li>
  221. <li><a href="../../component/imagezoom/index.html">imagezoom</a></li>
  222. <li><a href="../../component/menu/index.html">menu</a></li>
  223. <li><a href="../../component/menubutton/index.html">menubutton</a></li>
  224. <li><a href="../../component/mvc/index.html">mvc</a></li>
  225. <li><a href="../../component/overlay/index.html">overlay</a></li>
  226. <li><a href="../../component/promise/index.html">promise</a></li>
  227. <li><a href="../../component/resizable/index.html">resizable</a></li>
  228. <li><a href="../../component/rich-base/index.html">rich-base</a></li>
  229. <li><a href="https://github.com/jquery/sizzle/wiki/Sizzle-Home">sizzle</a></li>
  230. <li><a href="../../component/stylesheet/index.html">stylesheet</a></li>
  231. <li><a href="../../component/swf/index.html">swf</a></li>
  232. <li><a href="../../component/switchable/index.html">switchable</a></li>
  233. <li><a href="../../component/tabs/index.html">tabs</a></li>
  234. <li><a href="../../component/tree/index.html">tree</a></li>
  235. <li><a href="../../component/uri/index.html">uri</a></li>
  236. <li><a href="../../component/waterfall/index.html">waterfall</a></li>
  237. <li><a href="../../component/xtemplate/index.html">xtemplate</a></li>
  238. </ul>
  239. </ul>
  240. </div>
  241. </div>
  242. <script>
  243. if(!$.trim($(".col-extra").html())){
  244. $("#layout").removeClass("grid-s6m0e7").addClass("grid-s6m0");
  245. }
  246. </script>
  247. </div>
  248. <div id="footer">
  249. &copy; Copyright 2010~2012, KISSY Team. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>
  250. </div>
  251. </body>
  252. </html>