代码
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> table { width: 600px; height: 500px; margin: 30px auto; } table,tr,td { border: 2px double #ccc; text-align: center; } .bg1 { background-color: wheat; color: red; } </head> </style> <body> <div> <table> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td><span>5</span></td> </tr> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td><p>5</p></td> </tr> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5 <span></span></td> </tr> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> </tr> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> </tr> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> </tr> </table> </div> </body> </html> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <script type="text/javascript"> // $('table').find('tr').css('color','red') // $('td').children('p').css('color','orange') // $('tr:nth-child(2)').next().css('background-color','wheat') // $('tr:nth-child(2)').nextAll().addClass('bg1') // $('tr:nth-child(2)').prev().css('background-color','skyblue') // $('tr:odd').css('background-color','skyblue') $('td:even').css('background-color','wheat') $('*').removeAttr('style') // $(':empty()').html('i find you') // $('td').each(function(){ // $(this).css('color','red') // // }) // $('tr:last-child').css('color','red') $('*').removeAttr('style') $('tr').filter(':eq(2)').css('background-color','wheat') </script>