有关JQuery插入层层,请大佬指点.

daswcszxw 2013-11-08 03:04:33
1.我在<div caltag="b_onmouse"> 新增了一个属性.
2.通过这个属性

$(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的时候改变它的背景色

现在问题来了
我想要的层是一个呈现在DIV上面的层.怎么办?

下面是写的测试代码.

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");
});
})
//怎么都不行呢?求大佬指点.
...全文
189 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
daswcszxw 2013-11-11
  • 打赏
  • 举报
回复
求解答.或者我思路有问题吗?
EVKJ 2013-11-08
  • 打赏
  • 举报
回复
z-index:1000;
daswcszxw 2013-11-08
  • 打赏
  • 举报
回复
引用 4 楼 janey_he 的回复:

<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就可以了
层.谢谢.
yang_1224 2013-11-08
  • 打赏
  • 举报
回复
可不可以在这个div上面再浮现一个层 其z-index的值高于原来的层 为新添加的层设置透明度就可以实现123456不能选了
苹果没有皮 2013-11-08
  • 打赏
  • 举报
回复

<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就可以了
daswcszxw 2013-11-08
  • 打赏
  • 举报
回复
顶上去哦.
SummerKs 2013-11-08
  • 打赏
  • 举报
回复
写的 不够详细。。。。没看懂额。。。。
daswcszxw 2013-11-08
  • 打赏
  • 举报
回复

<!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.

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧