Tips Belajar Jquery Mengenal Selector JQuery Basic Filter (:odd)

Mengenal Selector JQuery Basic Filter (:odd)

match odd elements

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="../jquery-latest.js"></script>

  <script>
  $(document).ready(function(){
    $("tr:odd").css("background-color", "#bbbbff");
  });
  </script>
  <style>
  table {
    background:#f3f7f5;
  }
  </style>
</head>
<body>
  <table border="1">
    <tr><td>Row with Index #0</td></tr>
    <tr><td>Row with Index #1</td></tr>
    <tr><td>Row with Index #2</td></tr>
    <tr><td>Row with Index #3</td></tr>
  </table>
</body>
</html>

Perintah

$(“tr:odd”).css(“background-color”, “#bbbbff”);

tadinya saya bingung juga dengan kata-kata odd setelah lihat cara kerjanya ternyata odd itu disini diartikan ganjil.

digunakan untuk menset css “background-color”, “#bbbbff” pada tr yang ganjil dalam suatu table didocument html.

1 comment to Tips Belajar Jquery Mengenal Selector JQuery Basic Filter (:odd)

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>