ITeye博客

jquery each and find

夜鸣猪 · 2013-03-06 04:14 · javascript Jquery ext prototype · 编程语言 · Markdown


$(document).ready(function () {
    var selectedTable = $('table').eq('9');

    $(selectedTable).css('border','10px solid green');

    $(selectedTable).find('tr td').each(function(i) {
        $(this).css('border','10px solid blue');
    });
});



<!DOCTYPE html>
<html>
<head>
  <style>
  ul { font-size:18px; margin:0; }
  span { color:blue; text-decoration:underline; cursor:pointer; }
  .example { font-style:italic; }
  </style>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
  To do list: <span>(click here to change)</span>
  <ul>
    <li>Eat</li>
    <li>Sleep</li>
 
    <li>Be merry</li>
  </ul>
<script>
    $( "span" ).click(function () {
      $( "li" ).each(function(){
        $( this ).toggleClass( "example" );
      });
    });
 
</script>
 
</body>
</html>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。