87,907
社区成员
发帖
与我相关
我的任务
分享
$(document).ready(function(){
$("[caltag='b_onmouse']").hover(function(){
$(this).css("opacity","0.8");
$(this).css("cursor","pointer");
$(this).attr("bg",bgb).css("background-color","#FFFF93");
},function(){
$(this).css("background",bgb).removeAttr("bg");
});
})//hover的时候改变它的背景色
bgb = ($("[caltag='b_onmouse']").css("background"));
bgw = ($("[caltag='b_onmouse']").css("width"));
bgh = ($("[caltag='b_onmouse']").css("height"));
$(document).ready(function(){
$("[caltag='b_onmouse']").hover(function(){
$(this).css("opacity","0.8");
$(this).css("cursor","pointer");
$(this).attr("bg",bgb).css("background-color","#FFFF93");
//$("div > span").css("position","absolute");
//$("div > span").css("z-index","-1");
$(this).css("position","absolute");
$(this).css("z-index","-1");
},function(){
$(this).css("background",bgb).removeAttr("bg");
$(this).img("width",bgb).removeAttr("bgw");
$(this).img("height",bgh).removeAttr("bgh");
//$("div > span").css("position","static");
//$("div > span").css("z-index","1");
$("this").css("position","static");
$("this").css("z-index","1");
});
})
//怎么都不行呢?求大佬指点.
<div class="none-select" caltag="b_onmouse" style="width:500px;height:300px;margin:0 auto;background-color:#ccc;">
123456
</div>
<style>
.none-select{
-moz-user-select: none; /*火狐*/
-webkit-user-select: none; /*webkit浏览器*/
-ms-user-select: none; /*IE10*/
-khtml-user-select: none; /*早期浏览器*/
user-select: none;
}
</style>
是要一个文字不能选中的效果吗?是不是这样呢,css就可以了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
</head>
<body>
<div caltag="b_onmouse" style="width:500px;height:300px;margin:0 auto;background-color:#ccc;">
123456
</div>
</body>
</html>
<script type="text/javascript">
bgb = ($("[caltag='b_onmouse']").css("background"));
bgw = ($("[caltag='b_onmouse']").css("width"));
bgh = ($("[caltag='b_onmouse']").css("height"));
$(document).ready(function(){
$("[caltag='b_onmouse']").hover(function(){
$(this).css("opacity","0.8");
$(this).css("cursor","pointer");
$(this).attr("bg",bgb).css("background-color","#FFFF93");
//$("div > span").css("position","absolute");
//$("div > span").css("z-index","-1");
//$(this).css("position","absolute");
//$(this).css("z-index","-1");
},function(){
$(this).css("background",bgb).removeAttr("bg");
//$(this).img("width",bgb).removeAttr("bgw");
//$(this).img("height",bgh).removeAttr("bgh");
//$("div > span").css("position","static");
//$("div > span").css("z-index","1");
//$("this").css("position","static");
//$("this").css("z-index","1");
});
})
</script>
想要的效果是,hover层的时 无法选择123456.