首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

鼠标容易跟随提示二

2013-02-03 
鼠标简单跟随提示二function id(s){return document.getElementById(s)}/** * 鼠标跟随提示 */function m

鼠标简单跟随提示二

function id(s){return document.getElementById(s);}/** * 鼠标跟随提示 */function mouseFollow() {var e = e ? e : window.event;var posx = e.clientX;var posy = e.clientY;var followDiv = id("followDiv") ? id("followDiv"): document.createElement("div");followDiv.setAttribute("id","followDiv");var css = "width:100px;height:20px;border:1px solid grey;position:absolute;z-index:10000;left:"+posx+";top:"+posy+";";setCss(followDiv,css);document.body.appendChild(followDiv);}/** * element:需要获取样式的目标元素;name:样式属性 */ function getStyle(element, name) {var computedStyle;try {computedStyle = document.defaultView.getComputedStyle(element, null);} catch (e) {computedStyle = element.currentStyle;}if (name != "float") {return computedStyle[name];} else {return computedStyle["cssFloat"] || computedStyle["styleFloat"];}}/** * element:需要设置样式的目标元素;name:样式属性;value:设置值 */ function setStyle(element, name, value) {if (name != "float") {element.style[name] = value;} else {element.style["cssFloat"] = value;element.style["styleFloat"] = value;}}/** *  */function setCss(obj,css){obj.setAttribute("style",css);obj.style.cssText = css;}

?

热点排行