2017-01-04 84 views
1

我目前正在爲我的網站創建多個導航按鈕,它們中的每一個都會顯示菜單。使用文檔點擊功能事件後菜單不顯示

因此,作爲例子,這是第一個菜單:

<div class="outer-bar"> 
    <ul class="down-bar" style="list-style:hidden"> 
     <li> 
      <label id="down-nav-1" class="down-nav" onclick="Dropdown1()">Knives <b class="caret_down">&#9660;</b></label> 
      <div class="mainsizer"> 
       <div class="dropdown-menus" id="dropdown-menu-1"> 
        <a href=/?search=M9%20Bayonet&type=weapon class="Text1"><label class="m9_bayonet" style="width:30px;height:30px;position:absolute;top:5px;left:5px;cursor:pointer;"></label>M9 Bayonet</a> 
        <a href=/?search=Karambit&type=weapon class="Text1"><label class="karambit" style="width:30px;height:30px;position:absolute;left:5px;top:59px;cursor:pointer;"></label>Karambit</a> 
        <a href=/?search=Bayonet&type=weapon class="Text1"><label class="bayonet" style="width:30px;height:30px;position:absolute;left:5px;top:116px;cursor:pointer;"></label>Bayonet</a> 
        <a href=/?search=Butterfly%20Knife&type=weapon class="Text1"><label class="butterfly" style="width:30px;height:30px;position:absolute;left:5px;top:170px;cursor:pointer;"></label>Butterfly Knife</a> 
        <a href=/?search=Flip%20Knife&type=weapon class="Text1"><label class="flip" style="width:30px;height:30px;position:absolute;left:5px;top:225px;cursor:pointer;"></label>Flip Knife</a> 
        <a href=/?search=Falchion%20Knife&type=weapon class="Text1"><label class="falchion" style="width:30px;height:30px;position:absolute;left:5px;top:280px;cursor:pointer;"></label>Falchion Knife</a> 
        <a href=/?search=Gut%20Knife&type=weapon class="Text1"><label class="gut" style="width:30px;height:30px;position:absolute;left:5px;top:334.5px;cursor:pointer;"></label>Gut Knife</a> 
        <a href=/?search=Shadow%20Daggers&type=weapon class="Text1"><label class="shadow" style="width:30px;height:30px;position:absolute;left:5px;top:390px;cursor:pointer;"></label>Shadow Daggers</a> 
        <a href=/?search=Huntsman%20Knife&type=weapon class="Text1"><label class="huntsman" style="width:30px;height:30px;position:absolute;left:5px;top:444px;cursor:pointer;"></label>Huntsman Knife</a> 
        <a href=/?search=Bowie%20Knife&type=weapon class="Text1"><label class="bowie" style="width:30px;height:30px;position:absolute;left:5px;top:498.5px;cursor:pointer;"></label>Bowie Knife</a> 
       </div> 
      </div> 
     </li> 

所以當你在<label>元素#下調NAV-1,它已經onclick屬性鏈接到功能Dropdown1()和菜單的Display是看None和時間。

這是函數本身在Javascript:

function Dropdown1() { 
    document.getElementById("dropdown-menu-1").style.display = "inline-block"; 
    document.getElementById("down-nav-1").style.cssText = "border: solid 3px gray;background-color: gray;border-radius: 10px;"; 
} 

所有這一切只會工作精細,請參閱Fiddle。 (只有「刀」按鈕工程atm)。

但後來我嘗試添加功能,所以當用戶點擊菜單之外,顯示器將被設置爲「無」再次:

function Dropdown1() { 
    document.getElementById("dropdown-menu-1").style.display = "inline-block"; 
    document.getElementById("down-nav-1").style.cssText = "border: solid 3px gray;background-color: gray;border-radius: 10px;"; 
} 

$(document).click(function(event) { 
    if(!$(event.target).closest('#dropdown-menu-1').length) { 
     if (($('#dropdown-menu-1').style.display = "None") { 
      $('#dropdown-menu-1').style.display = "inline-block"; 
     } 
    } 
}) 

並添加該代碼後,就沒有點擊按鈕時的動作。 (see the result)。


我不明白在那裏的具體問題,但請注意,我是新來的Javascript,並不知道那裏有很多東西。

問題是什麼?我可以用純Javascript來做到這一點,或者我應該在這種情況下使用jquery嗎?

+2

或者只編寫這該死的東西正常,而僅使用HTML和CSS? JS不需要這麼簡單的事情。 – junkfoodjunkie

+0

@junkfoodjunkie我在過去使用過複選框輸入,但顯然僞元素不能與三叉戟佈局引擎一起使用。 ( IE瀏覽器 )。 – ShellRox

+0

呃,現在呢?你需要支持多久? – junkfoodjunkie

回答

1

有語法中的代碼&邏輯錯誤。

更新您的代碼:

function Dropdown1() { 
    if ($('#dropdown-menu-1').css("display") !== "none") { 
     $('#dropdown-menu-1').css("display", "none"); 
    } else { 
     $('#dropdown-menu-1').css("display", "inline-block"); 
    } 
    document.getElementById("down-nav-1").style.cssText = "border: solid 3px gray; background-color: gray; border-radius: 10px;"; 
} 

$(document).click(function(event) { 
    if (!$(event.target).closest('.outer-bar').length) { 
    if ($('#dropdown-menu-1').css("display") !== "none") { 
     $('#dropdown-menu-1').css("display", "none"); 
    } 
    } 
}); 

請您if塊內部比較時使用的=====代替=操作。

還有括號在if塊表達式中沒有關閉。

另外,style.display是與JavaScript對象關聯而不是jQuery對象關聯的屬性。您應該使用.css("display")作爲jQuery對象。

更新工作小提琴:https://jsfiddle.net/nashcheez/bjfz7twq/7/

+0

非常感謝修復,但不幸的是,它無法解決我的問題,當點擊外部菜單wouldn'關閉:https://jsfiddle.net/bjfz7twq/2/ – ShellRox

+0

@ShellRox我已經更新了我的答案,以準確地解決你的代碼和你的問題(沒有引入任何新的代碼),這應該是這裏接受的答案。 – nashcheez

+0

是的,它幾乎解決了我的問題,只是有一個小錯誤,當再次點擊外部時會打開它。 – ShellRox

1

如果您使用的是jQuery,請一致使用它。不要混用jQuery和Vanilla JavaScript。要做一些非常簡單的下拉式事情,你只需要使用JavaScript到只更改類而不是原來的效果。所有其他的應該由CSS處理。

從技術上講,這是可以實現的只是使用HTML和CSS。外面有1000多個例子。此外,您應該使用事件處理函數而不是函數來實現單個下拉列表,因爲它對於可伸縮性更好。

的第一件事,在CSS改變這個:

.mainsizer.open .dropdown-menus { 
    display: block; 
} 

而在你的JavaScript,這樣做:最終

$(function() { 
    $("label").click(function() { 
    if ($(this).next(".mainsizer").hasClass("open")) 
     $(this).next(".mainsizer").toggleClass("open"); 
    else { 
     $(".open").removeClass("open"); 
     $(this).next(".mainsizer").addClass("open"); 
    } 
    }); 
}); 

,你應該有這樣的代碼:

$(function() { 
 
    $("label").click(function() { 
 
    if ($(this).next(".mainsizer").hasClass("open")) 
 
     $(this).next(".mainsizer").toggleClass("open"); 
 
    else { 
 
     $(".open").removeClass("open"); 
 
     $(this).next(".mainsizer").addClass("open"); 
 
    } 
 
    }); 
 
});
.outer-bar { 
 
    position: relative; 
 
    display: block; 
 
    z-index: 1; 
 
    text-align: center; 
 
    top: 55px; 
 
    background-color: black; 
 
    height: 60px; 
 
    width: 100%; 
 
} 
 
.down-bar { 
 
    list-style-type: none; 
 
    font-size: 105%; 
 
} 
 
.down-bar li { 
 
    display: inline-block; 
 
    margin-top: 15px; 
 
    margin-right: 2%; 
 
    vertical-align: top; 
 
} 
 
.down-nav { 
 
    z-index: 1 
 
    font-size: 105%; 
 
    color: white; 
 
    font-family: 'Lato'; 
 
    cursor: pointer; 
 
    transition: all 0.1s ease; 
 
    -moz-transition: all 0.1s ease; 
 
} 
 
.down-nav:hover { 
 
    color: white; 
 
    border: solid 3px gray; 
 
    background-color: gray; 
 
    border-radius: 10px; 
 
    font-family: 'Lato'; 
 
} 
 
.down-nav li { 
 
    display: inline-block; 
 
} 
 
.caret_down { 
 
    font-size: 30%; 
 
} 
 
.mainsizer { 
 
    position: absolute; 
 
    width: 164px; 
 
} 
 
.dropdown-menus { 
 
    display: none; 
 
    position: absolute; 
 
    width: 164px; 
 
    right: 5%; 
 
    background-color: black; 
 
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); 
 
    z-index: 99; 
 
    transition: 0.1s ease-in; 
 
    margin-top: 5px; 
 
} 
 
.dropdown-menus a { 
 
    color: white; 
 
    text-align: center; 
 
    font-size: 0.9em; 
 
    padding: 8% 0px 15% 0%; 
 
    padding-right: 10%; 
 
    text-decoration: none; 
 
    display: block; 
 
    list-style-type: none; 
 
    white-space: nowrap; 
 
    margin-left: 0%; 
 
    text-indent: 4%; 
 
    font-family: 'Lato'; 
 
} 
 
.dropdown-menus a:hover { 
 
    background-color: gray; 
 
} 
 
.mainsizer.open .dropdown-menus { 
 
    display: block; 
 
}
<script src="https://code.jquery.com/jquery-2.2.4.js"></script> 
 
<div class="outer-bar"> 
 
    <ul class="down-bar" style="list-style:hidden"> 
 
    <li> 
 
     <label id="down-nav-1" class="down-nav" onclick="Dropdown1()">Knives <b class="caret_down">&#9660;</b></label> 
 
     <div class="mainsizer"> 
 
     <div class="dropdown-menus" id="dropdown-menu-1"> 
 
      <a href=/?search=M9%20Bayonet&type=weapon class="Text1"><label class="m9_bayonet" style="width:30px;height:30px;position:absolute;top:5px;left:5px;cursor:pointer;"></label>M9 Bayonet</a> 
 
      <a href=/?search=Karambit&type=weapon class="Text1"><label class="karambit" style="width:30px;height:30px;position:absolute;left:5px;top:59px;cursor:pointer;"></label>Karambit</a> 
 
      <a href=/?search=Bayonet&type=weapon class="Text1"><label class="bayonet" style="width:30px;height:30px;position:absolute;left:5px;top:116px;cursor:pointer;"></label>Bayonet</a> 
 
      <a href=/?search=Butterfly%20Knife&type=weapon class="Text1"><label class="butterfly" style="width:30px;height:30px;position:absolute;left:5px;top:170px;cursor:pointer;"></label>Butterfly Knife</a> 
 
      <a href=/?search=Flip%20Knife&type=weapon class="Text1"><label class="flip" style="width:30px;height:30px;position:absolute;left:5px;top:225px;cursor:pointer;"></label>Flip Knife</a> 
 
      <a href=/?search=Falchion%20Knife&type=weapon class="Text1"><label class="falchion" style="width:30px;height:30px;position:absolute;left:5px;top:280px;cursor:pointer;"></label>Falchion Knife</a> 
 
      <a href=/?search=Gut%20Knife&type=weapon class="Text1"><label class="gut" style="width:30px;height:30px;position:absolute;left:5px;top:334.5px;cursor:pointer;"></label>Gut Knife</a> 
 
      <a href=/?search=Shadow%20Daggers&type=weapon class="Text1"><label class="shadow" style="width:30px;height:30px;position:absolute;left:5px;top:390px;cursor:pointer;"></label>Shadow Daggers</a> 
 
      <a href=/?search=Huntsman%20Knife&type=weapon class="Text1"><label class="huntsman" style="width:30px;height:30px;position:absolute;left:5px;top:444px;cursor:pointer;"></label>Huntsman Knife</a> 
 
      <a href=/?search=Bowie%20Knife&type=weapon class="Text1"><label class="bowie" style="width:30px;height:30px;position:absolute;left:5px;top:498.5px;cursor:pointer;"></label>Bowie Knife</a> 
 
     </div> 
 
     </div> 
 
    </li> 
 
    <li> 
 
     <label id="down-nav-2" class="down-nav">Pistols <b class="caret_down">&#9660;</b></label> 
 
     <div class="mainsizer"> 
 
     <div class="dropdown-menus" id="dropdown-menu-2"> 
 
      <a href=?search=Glock-18&type=weapon><label class="glock-18" style="width:30px;height:23px;position:absolute;top:9.5px;left:4px;cursor:pointer;"></label>Glock-18</a> 
 
      <a href=?search=USP-S&type=weapon><label class="usp-s" style="width:30px;height:23px;position:absolute;top:59px;left:4px;cursor:pointer;"></label>USP-S</a> 
 
      <a href=?search=P2000&type=weapon><label class="p2k" style="width:30px;height:23px;position:absolute;top:106px;left:4px;cursor:pointer;"></label>P2000</a> 
 
      <a href=?search=Five-Seven&type=weapon><label class="five-seven" style="width:30px;height:23px;position:absolute;top:157px;left:4px;cursor:pointer;"></label>Five-SeveN</a> 
 
      <a href=?search=Desert%20Eagle&type=weapon><label class="desert-eagle" style="width:30px;height:23px;position:absolute;top:207px;left:4px;cursor:pointer;"></label>Desert Eagle</a> 
 
      <a href=?search=Tec-9&type=weapon><label class="tec9" style="width:30px;height:23px;position:absolute;top:258px;left:4px;cursor:pointer;"></label>Tec-9</a> 
 
      <a href=?search=CZ75-Auto&type=weapon><label class="cz75" style="width:30px;height:23px;position:absolute;top:307px;left:4px;cursor:pointer;"></label>CZ75-Auto</a> 
 
      <a href=?search=P250&type=weapon><label class="p250" style="width:30px;height:23px;position:absolute;top:357.5px;left:4px;cursor:pointer;"></label>P250</a> 
 
      <a href=?search=Dual%20Berettas&type=weapon><label class="dual_berettas" style="width:30px;height:30px;position:absolute;top:407px;left:4px;cursor:pointer;"></label>Dual Berettas</a> 
 
      <a href=?search=R8%20Revolver&type=weapon><label class="r8_revolver" style="width:30px;height:23px;position:absolute;top:461.5px;left:4px;cursor:pointer;"></label>R8 Revolver</a> 
 
     </div> 
 
     </div> 
 
    </li> 
 
    <li> 
 
     <label id="down-nav-4" class="down-nav">SMGs <b class="caret_down">&#9660;</b></label> 
 
     <div class="mainsizer"> 
 
     <div class="dropdown-menus" id="dropdown-menu-3"> 
 
      <a href=?search=P90&type=weapon><label class="p90" style="width:30px;height:23px;position:absolute;top:10px;left:8px;cursor:pointer;"></label>P90</a> 
 
      <a href=?search=MAC-10&type=weapon><label class="mac10" style="width:30px;height:23px;position:absolute;top:61px;left:8px;cursor:pointer;"></label>MAC-10</a> 
 
      <a href=?search=MP7&type=weapon><label class="mp7" style="width:30px;height:23px;position:absolute;top:111px;left:8px;cursor:pointer;"></label>MP7</a> 
 
      <a href=?search=MP9&type=weapon><label class="mp9" style="width:30px;height:23px;position:absolute;top:161px;left:8px;cursor:pointer;"></label>MP9</a> 
 
      <a href=?search=PP-Bizon&type=weapon><label class="pp-bizon" style="width:30px;height:23px;position:absolute;top:210px;left:8px;cursor:pointer;"></label>PP-Bizon</a> 
 
      <a href=?search=UMP-45&type=weapon><label class="ump45" style="width:30px;height:23px;position:absolute;top:261.5px;left:8px;cursor:pointer;"></label>UMP-45</a> 
 
     </div> 
 
     </div> 
 
    </li> 
 
    <li> 
 
     <label id="down-nav-5" class="down-nav">Rifles <b class="caret_down">&#9660;</b></label> 
 
     <div class="mainsizer"> 
 
     <div class="dropdown-menus" id="dropdown-menu-4"> 
 
      <a href=?search=AK-47&type=weapon><label class="ak47" style="width:30px;height:23px;position:absolute;top:9.5px;left:8px;cursor:pointer;"></label>AK-47</a> 
 
      <a href=?search=Galil%20Ar&type=weapon><label class="galil_ar" style="width:30px;height:23px;position:absolute;top:61px;left:8px;cursor:pointer;"></label>Galil AR</a> 
 
      <a href=?search=SG%20553&type=weapon><label class="sg553" style="width:30px;height:23px;position:absolute;top:111px;left:8px;cursor:pointer;"></label>SG 553</a> 
 
      <a href=?search=M4A4&type=weapon><label class="m4a4" style="width:30px;height:23px;position:absolute;top:161px;left:8px;cursor:pointer;"></label>M4A4</a> 
 
      <a href=?search=M4A1-S&type=weapon><label class="m4a1s" style="width:30px;height:23px;position:absolute;top:211.5px;left:8px;cursor:pointer;"></label>M4A1-S</a> 
 
      <a href=?search=AUG&type=weapon><label class="aug" style="width:30px;height:23px;position:absolute;top:261.5px;left:8px;cursor:pointer;"></label>AUG</a> 
 
      <a href=?search=Famas&type=weapon><label class="famas" style="width:30px;height:23px;position:absolute;top:311.5px;left:8px;cursor:pointer;"></label>Famas</a> 
 
     </div> 
 
     </div> 
 
    </li> 
 
    <li> 
 
     <label id="down-nav-6" class="down-nav">Snipers <b class="caret_down">&#9660;</b></label> 
 
     <div class="mainsizer"> 
 
     <div class="dropdown-menus" id="dropdown-menu-5"> 
 
      <a href=?search=AWP&type=weapon><label class="awp" style="width:30px;height:23px;position:absolute;top:9.5px;left:13.5px;cursor:pointer;"></label>AWP</a> 
 
      <a href=?search=SSG%2008&type=weapon><label class="ssg08" style="width:30px;height:23px;position:absolute;top:61px;left:13.5px;cursor:pointer;"></label>SSG 08</a> 
 
      <a href=?search=SCAR-20&type=weapon><label class="scar20" style="width:30px;height:23px;position:absolute;top:111px;left:13.5px;cursor:pointer;"></label>SCAR-20</a> 
 
      <a href=?search=G3SG1&type=weapon><label class="g3sg1" style="width:30px;height:23px;position:absolute;top:161px;left:13.5px;cursor:pointer;"></label>G3SG1</a> 
 
     </div> 
 
     </div> 
 
    </li> 
 
    <li> 
 
     <label id="down-nav-6" class="down-nav">Heavy <b class="caret_down">&#9660;</b></label> 
 
     <div class="mainsizer"> 
 
     <div class="dropdown-menus" id="dropdown-menu-6"> 
 
      <a href=?search=Nova&type=weapon><label class="nova" style="width:30px;height:23px;position:absolute;top:9.5px;left:13.5px;cursor:pointer;"></label>Nova</a> 
 
      <a href=?search=MAG-7&type=weapon><label class="mag-7" style="width:30px;height:23px;position:absolute;top:61px;left:13.5px;cursor:pointer;"></label>MAG-7</a> 
 
      <a href=?search=XM1014&type=weapon><label class="xm1014" style="width:30px;height:23px;position:absolute;top:111px;left:13.5px;cursor:pointer;"></label>XM1014</a> 
 
      <a href=?search=Sawed-Off&type=weapon><label class="sawed_off" style="width:30px;height:23px;position:absolute;top:161px;left:13.5px;cursor:pointer;"></label>Sawed-Off</a> 
 
      <a href=?search=Negev&type=weapon><label class="negev" style="width:30px;height:23px;position:absolute;top:211.5px;left:13.5px;cursor:pointer;"></label>Negev</a> 
 
      <a href=?search=M249&type=weapon><label class="m249" style="width:30px;height:23px;position:absolute;top:261.5px;left:13.5px;cursor:pointer;"></label>M249</a> 
 
     </div> 
 
     </div> 
 
    </li> 
 
    <li> 
 
     <label id="down-nav-7" class="down-nav">Others <b class="caret_down">&#9660;</b></label> 
 
     <div class="mainsizer"> 
 
     <div class="dropdown-menus" id="dropdown-menu-7"> 
 
      <a href=?search=Keys&type=weapon><label class="keys" style="width:30px;height:30px;position:absolute;top:6px;left:13.5px;cursor:pointer;"></label>Keys</a> 
 
      <a href=?search=Cases&type=weapon><label class="cases" style="width:30px;height:23px;position:absolute;top:61px;left:13.5px;cursor:pointer;"></label>Cases</a> 
 
      <a href=?search=Passes&type=weapon><label class="passes" style="width:30px;height:23px;position:absolute;top:105.5px;left:13.5px;cursor:pointer;"></label>Passes</a> 
 
      <a href=?search=Capsules&type=weapon><label class="capsules" style="width:30px;height:23px;position:absolute;top:156.5px;left:13.5px;cursor:pointer;"></label>Capsules</a> 
 
      <a href=?search=Pins&type=weapon><label class="pins" style="width:30px;height:30px;position:absolute;top:207px;left:13.5px;cursor:pointer;"></label>Pins</a> 
 
      <a href=?search=Packages&type=weapon><label class="packages" style="width:30px;height:14px;position:absolute;top:264.5px;left:13.5px;cursor:pointer;"></label>Packages</a> 
 
      <a href=?search=Stickers&type=weapon><label class="stickers" style="width:30px;height:30px;position:absolute;top:308px;left:13.5px;cursor:pointer;"></label>Stickers</a> 
 
      <a href=?search=Music%20Kits&type=weapon><label class="music_kits" style="width:30px;height:34px;position:absolute;top:356.5px;left:13.5px;cursor:pointer;"></label>Music Kits</a> 
 
     </div> 
 
     </div> 
 
    </li> 
 
    </ul> 
 
</div>

全屏輸出:http://output.jsbin.com/jeropupogu

+0

@ShellRox我還提供了一個全屏預覽...一旦你點擊菜單,如果還有其他東西打開,它會被關閉,然後當前菜單將被打開。如果當前菜單已打開,則關閉。這是我遵循的邏輯,希望這就是你需要的。 –

+0

非常感謝,它會打開菜單,但是當我的主要目標是在外部點擊菜單時關閉菜單。 (我也知道HTML複選框解決方案,只是試圖用三叉戟佈局引擎來適應網站)。 – ShellRox

+1

@ShellRox單擊外部,您可以使用Bootstrap所做的一個解決方案。我最近回答了它。讓我給你鏈接。 –

1

這裏有一個最小的,工作(雖然沒有完全風格)版本,不使用JS,也很基本的HTML和CSS。應該在任何瀏覽器中工作。

.nav { 
 
    display: block; 
 
    background-color: black; 
 
    height: 5em; 
 
} 
 
.nav a { 
 
    color: white; 
 
    } 
 
.nav ul { 
 
    list-style-type: none; 
 
    } 
 
.nav > ul > li { 
 
    display: inline-block; 
 
    } 
 
.nav ul li > ul { 
 
    display: none; 
 
    } 
 
.nav ul li:hover > ul { 
 
    display: block; 
 
    } 
 
.down-nav { 
 
    font-size: 105%; 
 
    color: white; 
 
    font-family: 'Lato'; 
 
    cursor: pointer; 
 
    transition: all 0.1s ease; 
 
    border: solid .2em transparent; 
 
} 
 
.down-nav:hover { 
 
    border: solid .2em gray; 
 
    background-color: gray; 
 
    border-radius: 1em; 
 
    font-family: 'Lato'; 
 
}
<div class="nav"> 
 
    <ul> 
 
    <li class="down-nav">Knives <span>&#9660;</span> 
 
     <ul> 
 
     <li><a href="/?search=M9%20Bayonet&type=weapon">M9 Bayonet</a></li> 
 
     <li><a href="/?search=Karambit&type=weapon">Karambit</a></li> 
 
     <li><a href="/?search=Bayonet&type=weapon">Bayonet</a></li> 
 
     <li><a href="/?search=Butterfly%20Knife&type=weapon">Butterfly Knife</a></li> 
 
     <li><a href="/?search=Flip%20Knife&type=weapon">Flip Knife</a></li> 
 
     <li><a href="/?search=Falchion%20Knife&type=weapon">Falchion Knife</a></li> 
 
     <li><a href="/?search=Gut%20Knife&type=weapon">Gut Knife</a></li> 
 
     <li><a href="/?search=Shadow%20Daggers&type=weapon">Shadow Daggers</a></li> 
 
     <li><a href="/?search=Huntsman%20Knife&type=weapon">Huntsman Knife</a></li> 
 
     <li><a href="/?search=Bowie%20Knife&type=weapon">Bowie Knife</a></li> 
 
     </ul> 
 
    </li> 
 
    <li class="down-nav">Pistols <span>&#9660;</span> 
 
     <ul> 
 
      <li><a href="/?search=Glock-18&type=weapon">Glock-18</a></li> 
 
      <li><a href="/?search=USP-S&type=weapon">USP-S</a></li> 
 
      <li><a href="/?search=P2000&type=weapon">P2000</a></li> 
 
      <li><a href="/?search=Five-Seven&type=weapon">Five-SeveN</a></li> 
 
      <li><a href="/?search=Desert%20Eagle&type=weapon">Desert Eagle</a></li> 
 
      <li><a href="/?search=Tec-9&type=weapon">Tec-9</a></li> 
 
      <li><a href="/?search=CZ75-Auto&type=weapon">CZ75-Auto</a></li> 
 
      <li><a href="/?search=P250&type=weapon">P250</a></li> 
 
      <li><a href="/?search=Dual%20Berettas&type=weapon">Dual Berettas</a></li> 
 
      <li><a href="/?search=R8%20Revolver&type=weapon">R8 Revolver</a></li> 
 
     </ul> 
 
    </li> 
 
    </ul> 
 
</div>

+0

謝謝,但我的主要目標不是懸停,我試圖點擊時打開菜單。 – ShellRox

+0

啊,那你就得用'>代替。 ':checked'應該可以在IE的所有後期版本中使用,所以只要你只需要支持IE 9+,那就可以正常工作。 – junkfoodjunkie

相關問題