Nees txaij ntxim rau cov natwm cov ntxhuav CSS los yog JQuery

Muab tus nyhuv bolinhas liab li cas, alternating cov xim natwm rau koj cov ntxhuav HTML? CSS los koj yuav JQuery!

CSS los yog jQuery?

Nws yog koj yam xaiv CSS (dua li) los yog JQuery. Nyob rau hauv qhov piv txwv nram qab no, Kuv xaiv los ua ib lub chav kawm ntawv .mytab mus ntawd immigration, focusing rau tej lus, xwb, tab sis rau cov uas yog mauj hauj. Qhov no, Koj yuav tsum qhia koj cov lus uas cov hoob kawm =”mytab”. Yog koj xav ua rau cov ntxhuav, hloov .mytab yog lossis cov lus. Ua li no, ib tsab sau ib cov lis dej num ntawm koj lub taub hau cim npe thiab npaj HTML.

Txoj siv CSS

1
2
3
4
5
6
7
8
<style type="text/css">
  .mytab tr:nth rau me nyuam(khib) {
    tom qab-twg:#FFF;
  }  
  .mytab tr:nth rau me nyuam(Txawm) {
    tom qab-twg:#CCC;
  } 
</style>

Txoj siv jQuery

1
2
3
4
5
6
7
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></tsab ntawv>
<script type="text/javascript">
$(daim ntawv).npaj txhij(muaj nuj nqi() {
   $('. mytab tr:khib ').CSS('tom qab-twg', '#ccc');
   $('. mytab tr:Txawm tias ').CSS('tom qab-twg', '#fff');  
});
</tsab ntawv>

Piv txwv

Teb chaws, hauv CSS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<HTML>
<lub taub hau>
<npe>Nees txaij</npe>
<style type="text/css">
  .mytab tr:nth rau me nyuam(khib) {
    tom qab-twg:#FFF;
  }  
  .mytab tr:nth rau me nyuam(Txawm) {
    tom qab-twg:#CCC;
  } 
</style>
</lub taub hau>
<lub cev>
    <table class="mytab">
      <THEAD>
        <tr>
          <th>Txiav txim</th>
          <th>Lub npe</th>
          <th>Hnub nyoog</th>
          <th>Xov tooj</th>
        </tr>
      </THEAD>
      <TBODY>
        <tr>
          <TD>1</TD>
          <TD>Maria</TD>
          <TD>45</TD>
          <TD>3434-6767</TD>
        </tr>
        <tr>
          <TD>2</TD>
          <TD>John</TD>
          <TD>12</TD>
          <TD>4545-9009</TD>
        </tr>
        <tr>
          <TD>3</TD>
          <TD>Marcos</TD>
          <TD>33</TD>
          <TD>9987-7655</TD>
        </tr>
        <tr>
          <TD>4</TD>
          <TD>Claudia</TD>
          <TD>21</TD>
          <TD>3409-5652</TD>
        </tr>
        <tr>
          <TD>5</TD>
          <TD>Juca</TD>
          <TD>7</TD>
          <TD>8981-7822</TD>
        </tr>
      </TBODY>
    </cov lus>
  </lub cev>
</HTML>
Tag nrho hits: 8883

2 lus rau “Nees txaij ntxim rau cov natwm cov ntxhuav CSS los yog JQuery

sau ntawv cia

Qhov koj email chaw nyob yuav tsis muab luam tawm. Search yog cim muaj *