鼠标简单跟随提示二

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;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值