设置对象的zIndex属性行不同啊????这是我写的帮忙看看,谢了 <script> <!-- function setCookie(top,left) { document.cookie="top="+top; document.cookie="left="+left; } function getCookie(name) { var mycookie=document.cookie; var start=mycookie.indexOf(name+"="); if (start!=-1) { start=mycookie.indexOf("=",start)+1; var end=mycookie.indexOf(";",start); if (end==-1) end=mycookie.length; var value=unescape(mycookie.substring(start,end)); if (value!=null) { var obj=document.getElementById("TheDiv"); if (name=="top") obj.style.top=value; if (name="left") obj.style.left=value; } } } function moveobj(obj) { var x=event.clientX; var y=event.clientY; obj.setCapture(); function obj.onmousemove() { if(obj) { var nx=event.clientX; var ny=event.clientY; window.status="X="+nx+"Y="+ny; obj.style.posLeft+=nx-x; obj.style.posTop+=ny-y; x=nx; y=ny; } } function obj.onmouseup() { var stop=0; obj.releaseCapture(); var nowtop=obj.style.top; var nowleft=obj.style.left; setCookie(nowtop,nowleft); obj=false; } } function setspan() { span1.style.background="red"; } //--> </SCRIPT> <div id="TheDiv" onmousedown="moveobj(this)" style=" float:left; position:absolute;width:200px;height:200px;background:#355ddd;border:1px #356999 solid;cursor:move; z-index:0;"></div> <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/> <span id="span1" style="width:100px;height:100px;background:#355ddd; z-index:1;" onmouseover="setspan();">sjdfkdsjfkdfj</span>
http://community.csdn.net/Expert/topic/4760/4760928.xml?temp=.3677942
只要设置对象的zIndex属性,使下面span的比上面div的大就可以了
或者设置css中的滤镜属性
filter:alpha(opacity=0)
用JS赋值的话可以用
obj.style.filter="alpha(opacity=0)"
语句实现
<script>
<!--
function setCookie(top,left)
{
document.cookie="top="+top;
document.cookie="left="+left;
}
function getCookie(name)
{
var mycookie=document.cookie;
var start=mycookie.indexOf(name+"=");
if (start!=-1)
{
start=mycookie.indexOf("=",start)+1;
var end=mycookie.indexOf(";",start);
if (end==-1)
end=mycookie.length;
var value=unescape(mycookie.substring(start,end));
if (value!=null)
{
var obj=document.getElementById("TheDiv");
if (name=="top")
obj.style.top=value;
if (name="left")
obj.style.left=value;
}
}
}
function moveobj(obj)
{
var x=event.clientX;
var y=event.clientY;
obj.setCapture();
function obj.onmousemove()
{
if(obj)
{
var nx=event.clientX;
var ny=event.clientY;
window.status="X="+nx+"Y="+ny;
obj.style.posLeft+=nx-x;
obj.style.posTop+=ny-y;
x=nx;
y=ny;
}
}
function obj.onmouseup()
{
var stop=0;
obj.releaseCapture();
var nowtop=obj.style.top;
var nowleft=obj.style.left;
setCookie(nowtop,nowleft);
obj=false;
}
}
function setspan()
{
span1.style.background="red";
}
//-->
</SCRIPT>
<div id="TheDiv" onmousedown="moveobj(this)" style=" float:left; position:absolute;width:200px;height:200px;background:#355ddd;border:1px #356999 solid;cursor:move; z-index:0;"></div>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<span id="span1" style="width:100px;height:100px;background:#355ddd; z-index:1;" onmouseover="setspan();">sjdfkdsjfkdfj</span>