Skip to content

Instantly share code, notes, and snippets.

@jmettraux
Created August 19, 2011 05:41
Show Gist options
  • Save jmettraux/1156132 to your computer and use it in GitHub Desktop.
Save jmettraux/1156132 to your computer and use it in GitHub Desktop.
$(document).ready( function() {
$('#menu').load('menu.html', function() {
console.log("loaded!");
//$('.menu > li').each( function(index) {
// // console.log("hello world "+ index);
// // $(this).find('.submenu').hide();
// var p = $(this).parent();
// var t = $(this);
// var s = $(this).find('.submenu');
// if (s) {
// var edge = p.offset().left + p.width();
// var test = s.offset().left + s.width();
// console.log(index + ": " + edge + " ? " + test);
// if (test < edge) {
// s.addClass("adjust");
// }
// }
//});
$('.menu > li > .submenu').each(function(index) {
var s = $(this);
var t = s.parent();
var p = $(t).parent();
var edge = p.offset().left + p.width();
var test = s.offset().left + s.width();
if (test < edge) {
s.addClass("adjust");
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment