jQuery日本語リファレンス

jQuery does not mean Japanese Query...

ヌー

Selectors/API/jQuery - Sample Code

:nth-child(index/even/odd/equation)

 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
 "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
 <script src="http://code.jquery.com/jquery-latest.js"></script>
 
 <script>
 $(document).ready(function(){
 
 $("button").click(function () {
 var str = $(this).text();
 $("tr").css("background", "white");
 $("tr" + str).css("background", "#e2e1fb");
 $("#inner").text(str);
 });
 });
 </script>
 <style>
 button { display:block; font-size:12px; width:100px; }
 div { float:left; margin:10px; font-size:10px; 
 border:1px solid black; }
 span { color:blue; font-size:18px; }
 #inner { color:red; }
 td { width:50px; text-align:center; }
 </style>
</head>
<body>
 <div>
 <button>:nth-child(even)</button>
 <button>:nth-child(odd)</button>
 <button>:nth-child(3n)</button>
 <button>:nth-child(2)</button>
 </div>
 <div>
 <button>:nth-child(3n+1)</button>
 <button>:nth-child(3n+2)</button>
 <button>:even</button>
 <button>:odd</button>
 </div>
 <div><table>
 <tr><td>John</td></tr>
 <tr><td>Karl</td></tr>
 <tr><td>Brandon</td></tr>
 <tr><td>Benjamin</td></tr>
 </table></div>
 <div><table>
 <tr><td>Sam</td></tr>
 </table></div>
 <div><table>
 <tr><td>Glen</td></tr>
 <tr><td>Tane</td></tr>
 <tr><td>Ralph</td></tr>
 <tr><td>David</td></tr>
 <tr><td>Mike</td></tr>
 <tr><td>Dan</td></tr>
 </table></div>
 <span>
 tr<span id="inner"></span>
 </span>
</body>
</html>
 
 
[実行結果] [フレーム]
[:nth-child(index/even/odd/equation) の説明へ]
© Copyright 2009 by semooh.jp | Design by Free CSS Templates - Thanks to Dubai Apartments

AltStyle によって変換されたページ (->オリジナル) /