OK, I htink Darin may have done something similar before, and I found some other shit that I felt was full of garbage, so what I done come up with I think is pretty simple. Basically it takes a css based hover menu, and turns it into a touch to open solution. I am using Modernizr’s Modernizr.touch attribute, but I reckon most of our stuff coming out prolly has Modernizr hooked up. And note, geared to touch… not some weird is mobile device craziness. Anywho, it also takes the parent link and text and adds it to the drop, then breaks the parent, so it is OK to have the parent as a page. Make sense?
//Make the drop menus more mobiletastic/touch friendly if (Modernizr.touch){ $('#main-nav li').has('ul').addClass('hasDrop'); $('.hasDrop > a').each(function(){ var topLink = $(this).attr("href"); var myLabel = $(this).text(); $(this).next('ul').prepend('<li><a href="'+topLink+'">'+myLabel+'</a></li>'); $(this).attr("href", "javascript:void(0)") }); };
Recent Comments