2012-11-06 40 views

Trả lời

5

heres một hàm Tôi đang sử dụng để có được những Dropdowns navbar để trượt xuống trên di chuột thay vì chỉ popping trong

$('.navbar .dropdown').hover(function() { 
    $(this).find('.dropdown-menu').first().stop(true, true).delay(250).slideDown(); 
}, function() { 
    $(this).find('.dropdown-menu').first().stop(true, true).delay(100).slideUp() 
}); 
11

1.Hide thả xuống menu trên mouseover.

$(document).ready(function() { 
    $('.nav li.dropdown').hover(function() { 
     $(this).addClass('open'); 
    }, function() { 
     $(this).removeClass('open'); 
    }); 
}); 

2.Hide thả xuống menu trên nhấp chuột.

$(document).ready(function() { 
    $('.nav li.dropdown').hover(function() { 
     $(this).addClass('open'); 
    }); 
}); 

http://jsfiddle.net/7yMsQ/1/

+1

Ngoài ra thêm '$ ('nav li.dropdown'). RemoveClass ('mở'); 'là dòng đầu tiên trong hàm thứ 2 (đóng), do đó nếu bạn có nhiều trình đơn thả xuống, nó ẩn các phần tử khác có thể mở. –

Các vấn đề liên quan