如果按下相应的按钮,我有一个小脚本应该显示一个隐藏的 div。例如,如果单击按钮 first-button 比 div first-button-content 应该显示。现在,当我单击按钮时,chrome 崩溃并且 div 不显示。
这是html:
<div class="home-middle-buttons">
<div class="first-button">
<span>I’m an In-House Marketer</span>
</div>
<div class="second-button">
<span>I Work at an Agency</span>
</div>
<div class="third-button">
<span>I’m a Business Owner</span>
</div>
</div>
<div class="home-middle-content">
<div class="first-button-content">
<p>Lorem ipsum dolor</p>
</div>
<div class="second-button-content">
<p>Lorem ipsum dolor</p>
</div>
<div class="third-button-content">
<p>Lorem ipsum dolor.</p>
</div>
</div>
这是脚本:
jQuery(document).ready(function() {
jQuery(".home-middle-buttons div").click(function() {
if (jQuery(".first-button").click()) {
jQuery(".first-button-content").css( 'display', 'block' );
} else {
jQuery(".second-button-content").css( 'display', 'block' );
}
});
});