---
title: "jquery each and find"
author: "夜鸣猪"
date: "2013-03-06T04:14:26Z"
tags: []
categories: ["编程语言"]
slug: "jquery-each-and-find"
draft: false
lastmod: "2013-03-06T04:14:26Z"
id: 1823017
url: "https://hlee.iteye.com/blog/1823017"
---

```js

$(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');
    });
});

```





```html


<!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>

```