我正在尝试编写一个在display:none模式下关闭DIV的盲函数。看不见的DIV位于较宽的DIV中,其中包含盲触发器。
此:
$(document).ready(function () {
$("#toggle_blind").click(function () {
$(this).toggle("fast");
});
});
嗯,这使按钮变暗。如何将DIV添加到$ this?类似于:
<div id="blind" class="wider_div">
<h3 id="closeButton">Close</h3>
<div style="display:none;" id="closeThis">
<p>some text</p>
</div>
</div>
我如何使H3上的关闭按钮在每次单击时关闭/打开CloseButton DIV?
谢谢!
div是h3的下一个兄弟,因此您可以使用.next()
例如
$('#closeButton').click( function(){
$(this).next().toggle();
});
直接参考div,您可以在它和h3之间放置其他内容。
$(document).ready(function()
{
$("#closeButton").click(function()
{
$("#closeThis").toggle("fast");
});
});