jquery 1.4 append 用法

.append( function(index, html) )

function(index, html)A function that returns an HTML string to insert at the end of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments.

群里有人问,写个简单的demo

   1:  <script type="text/javascript">
   2:      $(function() {
   3:          $("li").append(function(index, html) {
   4:              if (index == 3) {
   5:                  html += "new append";
   6:              }
   7:              return html;
   8:          });
   9:      });
  10:  </script>
  11:   
  12:  <ul><li>111</li><li>22</li><li>33</li><li>44</li></ul>
posted @ 2010-06-04 10:37  looping  阅读(420)  评论(0编辑  收藏  举报