用js写鼠标移入li,div显示,移出消失

2024-11-14 08:46:27
推荐回答(2个)
回答1:

是 block,不是 bolck !!!

回答2:

12345678910111213141516171819202122232425function showDiv(i, blean) { var div = document.getElementById("div" + i); //获取绑定的 DIV if (div == undefined) { //如果 DIV,不存在,则创建 div = document.createElement("div"); div.id = "div" + i; //给ID 赋值,好下一次隐藏 div.style.position = "absolute"; div.style.marginLeft = "100PX"; div.style.width = "80px"; div.style.height = "80px"; div.style.left = i * 100 + 40 + "px"; div.style.border = "1px solid #ddd"; div.style.background = "red"; div.style.textAlign = "center"; div.innerHTML = "你好" + i; document.body.appendChild(div); } if (blean == 1) { div.style.display = "block"; //再显示 } else { div.style.display = "none"; //隐藏 }}