Sasa Posted January 24, 2009 Report Share Posted January 24, 2009 Esmu redzējis tādas tabulas kur katra otrā rinda ir citā krāsa un vēl iekš FF ir tā ka ar peli braukājot pa rindām tās vēl savādāk pārkrāsojas. Kā man kaut ko līdzīgu sataisīt savai tabulai? Link to comment Share on other sites More sharing options...
Evi Posted January 24, 2009 Report Share Posted January 24, 2009 tr.zils { background:blue } tr:hover { background:blue } // shis tev uztaisiis zilu bg, kad brauksi ar peli paari tabulas rindaam <tr class="zils"> <td>zils</td> </tr> <tr> <td>balts</td> </tr> Link to comment Share on other sites More sharing options...
NiTrino Posted January 25, 2009 Report Share Posted January 25, 2009 ar "pliku" css katru otro rindu iekrāsot nesanāks. Toties tam var palīdzēt PHP: $odd = $i%2==0?'odd':''; echo '<tr class="'.$odd.'">' un attiecīgi tr.odd { background:#ccc; } Link to comment Share on other sites More sharing options...
briedis Posted October 21, 2009 Report Share Posted October 21, 2009 (edited) Jquery te ir spēks :) JS $(document).ready(function(){ $("table#zebra tr:odd").addClass("highlighted"); }); HTML <table id="zebra"> <tr><td></td></tr> <tr><td></td></tr> <tr><td></td></tr> </table> CSS table#zebra tr.highlighted td{ background-color:green; } Edited October 21, 2009 by briedis Link to comment Share on other sites More sharing options...
marcis Posted October 21, 2009 Report Share Posted October 21, 2009 Briedi, tavs JS piešķirs klasi katrai otrajai kolonai, nevis katrai otrajai rindai :) Link to comment Share on other sites More sharing options...
briedis Posted October 21, 2009 Report Share Posted October 21, 2009 Sorry, apmudījos gudrībā :D Kļūda labota... Link to comment Share on other sites More sharing options...
mefisto Posted October 21, 2009 Report Share Posted October 21, 2009 Tātad ... lai uztaisītu hover efektu vajag izmantot jQuery ?!? Vai es esmu vienīgais, kuram tas liekas nedaudz debīli ? Un tas tavs kods tāpat nedarbojas. Anyway: http://innonesen.se/test/l-42/ Link to comment Share on other sites More sharing options...
briedis Posted October 21, 2009 Report Share Posted October 21, 2009 (edited) $(document).ready(function(){ $("table#zebra tr:odd").addClass("highlighted"); $("table#zebra tr").hover(function(){ $(this).addClass("hover"); },function(){ $(this).removeClass("hover"); }); }); CSS table#zebra tr.hover td{ background-color:green; } table#zebra tr.highlighted.hover td{ background-color:red; } A man liekas debīli rakstīt 70 rindiņas, ja var uzrakstīt 10 rindiņas... Un ne jau vienīgā vieta, kur var izmantot jquery ir liekot hover efektus... Edited October 21, 2009 by briedis Link to comment Share on other sites More sharing options...
Kavacky Posted October 21, 2009 Report Share Posted October 21, 2009 (edited) Vai es esmu vienīgais, kuram tas liekas nedaudz debīli ?Nebūsi vis. $(document).ready(function(){ $("table#zebra tr:odd").addClass("highlighted"); $("table#zebra tr").hover(function(){ $(this).addClass("hover"); },function(){ $(this).removeClass("hover"); }); }); A man liekas debīli rakstīt 70 rindiņas, ja var uzrakstīt 10 rindiņas.. 10 rindiņas ar jQuery vs: $i = 0; // ārpus cikla $i++; $highligh = $i % 2 ? '' : ' highlight'; echo '<rinda class="[..]', $hightlight, '">blah dati</rinda>'; Jeb - veselas 3 jaunas rindiņas + labojums ceturtajā. Ne tuvu minētajām 70 rindām. Un civilizēti browseri, cik atceros, saprot :hover pseidoklasi bez jebkādas JavaScript iejaukšanās. Edited October 21, 2009 by Kavacky Link to comment Share on other sites More sharing options...
briedis Posted October 21, 2009 Report Share Posted October 21, 2009 Kavacky, es tās 70 rindas sakarā mefisto hover minēto skriptu. Protams, ka ar php var iekrāsot pavisam elementāri... Jquery bija tikai alternatīva. Link to comment Share on other sites More sharing options...
mefisto Posted October 22, 2009 Report Share Posted October 22, 2009 emm ... oh augstais guru .. a tu piskaitīji klāt paša jquery.js rindu skaitu ? Link to comment Share on other sites More sharing options...
xPtv45z Posted October 22, 2009 Report Share Posted October 22, 2009 Ja jau skaitāt rindiņas, tad jquery produkcijas versijai, ir tikai 11 rindiņas, no kurām 10 ir komentāri. :D Link to comment Share on other sites More sharing options...
Recommended Posts