user3347903 user3347903 -4 years ago 168
jQuery Question

Bootstrap: Remake jQuery function to work on hover instead of click

I'm using bootstrap and got stuck.
The code below works on click. How can I remake it so it would work on hover? I'm a noob in jQuery..

.on('', '[data-toggle^="button"]', function (e) {
var $btn = $(
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')$btn, 'toggle')
.on('', '[data-toggle^="button"]', function (e) {
$('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type))

p.s. It seems like the important string is '[data-toggle^="button"]', since deleting this ruins the functionality
p.p.s. I've already read How to make twitter bootstrap menu dropdown on hover rather than click but it didn't help. I'd prefer not to ruin what I'v already done

Answer Source

Easy solution, is to make CSS

.dropdown:hover .dropdown-menu {
    display: block;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download