N
N
noname12016-01-17 17:28:40
Bootstrap
noname1, 2016-01-17 17:28:40

How to apply this script to bootstrap3 menu and not button?

jsfiddle.net/DarrenS/pcav6v1g

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
noname1, 2016-01-17
@noname1

//Non-Touch devices
//Hover expands menu (non default Bootstrap behaviour)
$('html.no-touch li.dropdown').hover(function(e) {
  $(this).toggleClass('open');
});

//Non-Touch devices
//Click follows main link (non default Bootstrap behaviour)
$('html.no-touch li.dropdown a.dropdown-toggle').on('click', function(e) {
  e.preventDefault();
  window.location.href = $(this).attr('href');
})

//Touch devices
//Touch (click) expands menu (default Bootstrap behaviour)

//Touch devices
//Allow touch (click) to follows main link when menu open (non default Bootstrap behaviour)
$('html.touch li.dropdown.open a.dropdown-toggle').on('click', function(e) {
  e.preventDefault();
  window.location.href = $(this).attr('href');
})

Thanks to all. Understood. I needed more
to plug...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question