我有以下的html:如何通过jQuery
<div class="contentBlock">
<div><img src="images/help.png" alt="help button" class="helpButton"></div>
<div class="helpBlock">
<p>...some hidden text...</p>
</div> <!-- end .helpBlock -->
<h2>A Header</h2>
<p>...some visible text...</p>
</div> <!-- end .contentBlock -->
我有以下的CSS:
div.contentBlock {
position: relative; /* required for z-index */
z-index: 1; /* interacts with div.helpBlock */
}
div.helpBlock {
display: none;
position: relative; /* required for z-index */
z-index: 10; /* interacts with div.contentBlock */
}
我有以下的jQuery:
$(document).ready(function() {
// Show helpBlock on page
$('img.helpButton').click(function(){
/*$(this).closest('.helpBlock').show();*/ // does not work
/*$(this).closest('.helpBlock').css('display');*/ // does not work
var $contentWrapper = $(this).closest('.helpBlock');
var $siblings = $contentWrapper.siblings('.helpBlock');
$siblings.find('.helpBlock').show(); // does not work
});
// end Show helpBlock
}) // end jQuery Functions
我试图让我.helpBlock显示,当我点击帮助按钮,但没有我的jquery工作。
任何人都可以协助吗?
THanks。
优秀。谢谢@LifeInTheGrey。这工作! – 2013-03-06 18:35:54
不要感谢我,谢谢复选标记。 ;) – PlantTheIdea 2013-03-06 18:36:22
请考虑标记这个答案与复选框,以显示如果解决您的问题:) – 2013-03-06 18:38:03