我有以下html:
<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 都没有工作。
有人可以帮忙吗?
谢谢。