当链接悬停时,我试图显示一些隐藏的内容。每个链接的内容都是唯一的。我让它工作正常,但我知道 jQuery 代码很糟糕。我认为“.this”是秘密,但我无法让它发挥作用。有什么想法吗?这是有史以来最丑陋的低效废话 jQuery,但我正在努力解决这个问题。谢谢!
jQuery
$(document).ready
(
function(){
$(".short-term-trigger").hover(function(){
$(".short-term").toggleClass("visible");
});
}
)
$(document).ready
(
function(){
$(".medium-term-trigger").hover(function(){
$(".medium-term").toggleClass("visible");
});
}
)
$(document).ready
(
function(){
$(".long-term-trigger").hover(function(){
$(".long-term").toggleClass("visible");
});
}
)
$(document).ready
(
function(){
$(".retirement-trigger").hover(function(){
$(".retirement").toggleClass("visible");
});
}
)
HTML
<ul id="goal-btns">
<li><a class="short-term-trigger" href="#">Short-Term Gains</a></li>
<li><a class="medium-term-trigger" href="#">Medium Term Goals</a></li>
<li><a class="long-term-trigger" href="#">Long Term Goals</a></li>
<li><a class="retirement-trigger" href="#">Retirement</a></li>
</ul>
<div class="talk-bubble hang-left short-term">
<p class="bubble-text">I’ll need the money is less than 12 months.</p>
</div><!--/short-gains-->
<div class="talk-bubble hang-right medium-term">
<p class="bubble-text">I don’t need the money immediately but may need it within the next 6-10 years.</p>
</div><!--/short-gains-->
<div class="talk-bubble hang-right long-term">
<p class="bubble-text">I’m investing for the long-term.</p>
</div><!--/short-gains-->
<div class="talk-bubble hang-right retirement">
<p class="bubble-text">I’m investing for my retirement.</p>
</div><!--/short-gains-->