<html lang="en">
<head>
<title>判断display为隐藏还是显示及获取css</title>
</head>
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(function()
{
var a=$("#div1"); //我是分开写的,比较详细点
a.click(function()
{
$("#div1").css("background","yellow");//鼠标单击更改背景色
$("#div1").html("已经开始执行click了");//鼠标单击更改html
//判断是否点击
var b=$("#div2").css("display");//获取div2的dispaly
if(b=="none")//如果display为none,我们就让它显示! 如果为block,就让它隐藏!
{
$("#div2").css("display","block");
}
else
{
$("#div2").css("display","none");
}
});
});
</script>
<body>
<div id="div1" style="width:200px;">12311</div>
<div id="div2" style="width:500px;display:none;height:40px;background:#FF0;">12311</div>
</body>
</html>