2
.comments{cursor:pointer;}
.hidediv{visibility:hidden;}
HTML:
<span id="agreeComments" class="comments b">Comments</span><br /><br />
<div id="divAgree" class="hidediv">
<asp:PlaceHolder runat="server" ID="plcAgreements" ClientIDMode="Inherit" />
</div>
的jQuery:
<script>
$(document).ready(function() {
$("#agreeComments").click(function() {
if ($("#divAgree").is(":hidden")) {
$("#divAgree").slideDown("slow");
} else {
$("#divAgree").slideUp("slow");
$("#plcAgreements").show();
}
}
);
});
</script>
我使用上面的代码隐藏和使用显示一个div jQuery的。我有一个在div内的asp占位符控件。加载页面时我需要隐藏div,并且在点击评论时需要显示或隐藏。 Div正在隐藏,但问题是占用了asp占位符的空间。
使用.hidediv {显示:无;},而不是在CSS visibility属性。 –