js 中设置元素样式
有两种方法:
1. ele.setAttribute("border");
2. ele.style.border = ""
注意:ele.getAttribute("border")只能获取 setAttribute 的样式,对于 .style 设置的样式会返回 null
style 和 setAttribute 不要混合用!
/* Pic.setAttribute("position", "absolute");*/ //这样会不起作用
Pic.style.position = "absolute";
Pic.style.top = event.pageY + "px";
Pic.style.left = event.pageX + "px";
Pic.style.position = "absolute";
Pic.style.top = event.pageY + "px";
Pic.style.left = event.pageX + "px";