Posted By


masaya on 01/14/07

Tagged


Statistics


Viewed 637 times
Favorited by 1 user(s)

Related snippets


hightlight-list.js


/ Published in: JavaScript
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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;

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.