function Actshow(tag)
{
var obj=document.getElementById(tag).style.display; //本想通过改display:none和block;来改变cc和dd的动态显示的
alert(obj); //弹出的对话框为空?为什么?有办法取到cc或dd的diasplay的值吗?
...
}
...
<div>
<div id="aa" onmouseover="javascript:ActShow('cc');" >aa</div>
<div id="bb" onmouseover="javascript:ActShow('dd');" >bb</div>
</div>
<div>
<div id="cc">cc</div>
<div id="dd">dd</div>
</div>
...
<div id="cc" style="display:block;">cc</div>
<div id="dd" style="display:block;">dd</div>
function ActShow(tag)
{
var element = document.getElementById(tag);
var styles = element.currentStyle || document.defaultView.getComputedStyle(element,null);
alert(currentStyle['display']);
}
</script>
函数这样来写就可以了了
function ActShow(tag)
{
var element = document.getElementById(tag);
var styles = element.currentStyle || document.defaultView.getComputedStyle(element,null);
alert(styles['display']);
}
</script>
应该是这样,sorry!!
return element.currentStyle || document.defaultView.getComputedStyle(element, null);
};
var obj = getCurrentStyle(document.getElementById(tag)).display;
alert(obj)