Posted By

masaya on 01/14/07


Tagged

javascript


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

shachi
vali29
korzhik


hightlight-list.js


 / Published in: JavaScript
 

URL: http://masaya-sugawara.com/

交互に背景色を変えるスクリプト. XHTML basic templateと合わせて参考にどうぞ. 本当はCSSクラスを振って, スタイルはCSSで付けたほうがいいけど取り急ぎ.

  1. setHighLight = function() {
  2. var sub = document.getElementById("sub");
  3. var ul = sub.getElementsByTagName("ul");
  4. for(var i=0; i<ul.length; i++) {
  5. var li = ul[i].getElementsByTagName("li");
  6. for(var j=0; j<li.length; j++) {
  7. li[j].style.background = (j%2) ? "#fff" : "#e5ecf9";
  8. }
  9. }
  10. }
  11.  
  12. function init() {
  13. setHighLight();
  14. }
  15.  
  16. window.onload = init;

Report this snippet  

You need to login to post a comment.