jQuery:切换下拉菜单的可能性 [英] jQuery: Toggle Dropdown Menu Possibility
问题描述
我在下面有以下HTML,但是我想知道有可能使用jQuery .toggle
函数将主<li>
标题 Trails 设置为链接,然后您将鼠标置于主链接 Trails 上,其他页面将显示,您可以单击相应页面.
I have the following HTML below but what I was wanting to know is it possible to use the jQuery .toggle
function to enable the main <li>
heading Trails to be a link and then when you put the mouse over the main link Trails the other pages will show and you can click on the respective page.
HTML:-此HTML格式由PYROCMS提供,我对此无能为力
<li class="current">
<a href="">Trials</a>
<ul>
<li class="first">
<a href="">Link One</a>
</li>
<li>
<a href="">Link Two</a>
</li>
<li>
<a href="">Link Three</a>
</li>
<li class="last">
<a href="">Link Four</a>
</li>
</ul>
</li>
jQuery:-是否可以将以下版本用于上述问题?
$('select[name="domainTransfer"]').change(function() {
$('#domainToBeTransfered,#domainToBeTransfered0').toggle($(this).val() === "yes");
});
Baz1nga:
我看了看您的jsfiddle,发现您在子<ul>
上放置了display:none;
,我将css中的行放置为#wrapper #contentarea #blue_box .centerblue_txt ul li ul{
,但它似乎与jQuery无关.
I have looked at your jsfiddle and noticed you have placed a display:none;
on the sub <ul>
I have placed that into my css the line is #wrapper #contentarea #blue_box .centerblue_txt ul li ul{
but it does not seem to interact with the jQuery.
jQuery(document).ready(function () {
$(".current a").mouseenter(function(){
$(this).siblings("ul").show();
}).mouseout(function(){
$(this).siblings("ul").hide();
});
});
推荐答案
$(".current a").mouseenter(function(){
$(this).siblings("ul").show();
}).mouseleave(function(){
$(this).siblings("ul").hide();
});
这是您想要的吗?
演示: http://jsfiddle.net/rY8zm/
这篇关于jQuery:切换下拉菜单的可能性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!