所以這已經引起了我很多頭痛。 我正在製作「下拉式手風琴子菜單」(缺乏更好的名稱)。 我的腳本可以使用,但只能在HOVER上使用。如果我嘗試使用.click,.on(「click」),.on(「click」,「li」)等等。該腳本僅在使用.hover時有效。.hover Works,點擊並不是
注意! 這只是應該有點擊事件的「#TopMenu」。子菜單(「#accordion」)將會懸停。
任何想法?
工作:
$(document).ready(function() {
$('#accordion li').hover(function() {
$(this).find('ul').stop(true, true).slideDown()
}, function() {
$(this).find('ul').stop(true, true).slideUp()
}).find('ul').hide()
$('#TopMenu li').hover(function() {
$(this).find('li').stop(true, true).slideDown()
}, function() {
$(this).find('li').stop(true, true).slideUp()
}).find('li').hide()
});
更改 「#TopMenu」 點擊不工作:
$(document).ready(function() {
$('#accordion li').hover(function() {
$(this).find('ul').stop(true, true).slideDown()
}, function() {
$(this).find('ul').stop(true, true).slideUp()
}).find('ul').hide()
$('#TopMenu li').on('click', function() {
$(this).find('li').stop(true, true).slideDown()
}, function() {
$(this).find('li').stop(true, true).slideUp()
}).find('li').hide()
});
我這裏有一個工作測試:http://jsbin.com/nidazuq/3/embed?html,js,output
我在此將堅果,我已經搜索了高和低的解決方案。請幫忙。
您是否也可以添加HTML標記以用於演示目的? – guradio
您的「工作測試」似乎不起作用 – Tibrogargan