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");
});
})
//怎么都不行呢?求大佬指点.

解决方案 »

  1.   


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

  2.   


    <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就可以了
      

  3.   

    可不可以在这个div上面再浮现一个层 其z-index的值高于原来的层 为新添加的层设置透明度就可以实现123456不能选了