LoginSignup
1
0

More than 5 years have passed since last update.

javascriptのみでhtmlとcss実装してみた hover編

Last updated at Posted at 2018-06-06

煩雑さはご愛嬌です

var ul = document.createElement("ul");
nav.appendChild(ul);
var li = new Array(3);
var a = new Array(3);
for(var i=0; i<=3; i++){
li[i] = document.createElement("li");
ul.appendChild(li[i]);
a[i] = document.createElement("a");
a[i].attribute = "href";
a[i].setAttribute("href","");
li[i].appendChild(a[i]);
//hover
li[i].attribute="onmouseover";
li[i].setAttribute("onmouseover", "this.style.backgroundColor='#996633',firstChild.style.color='white'");
li[i].attribute="onmouseout";
li[i].setAttribute("onmouseout", "this.style.backgroundColor='white',firstChild.style.color='#996633'");
}

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0