W jaki sposób można pogrubic parzyste wiersze listy LI..?
Próbowalem w ten sposób, ale nie chce działać.
Mam liste:
styl css:
#lista_pozycji li:nth-child(even) { font-weight: bold; } #lista_pozycji li:nth-child(odd) { font-weight: none; }
#lista_pozycji li:nth-child(even) { font-weight: bold; } #lista_pozycji li:nth-child(odd) { font-weight: none; }
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <script type="text/javascript"> function $(id) { return document.getElementById(id); } window.onload = function() { lists = new Array('raz', 'dwa', 'trzy'); colors = new Array('red', 'green'); for(var i=0;i<lists.length;i++) { if($(lists[i]).hasChildNodes()) { var elements = $(lists[i]).childNodes; var p = 0; for(var j=0;j<elements.length;j++) { if(elements[j].nodeType == 1) { elements[j].style.backgroundColor = colors[p]; p = (p>=colors.length-1 ? 0 : p+1); } } } } } </script> </head> <body> <ul id="raz"> <li>jeden <li>dwa <li>trzy <li>cztery <li>piec <li>szecs </ul> <ul id="dwa"> <li>jeden <li>dwa <li>trzy <li>cztery <li>piec <li>szecs </ul> <ol id="trzy"> <li>jeden <li>dwa <li>trzy <li>cztery <li>piec <li>szecs </ol> </body> </html>