Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dingo-d
Last active February 24, 2016 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dingo-d/d917ddebd65be700fbcb to your computer and use it in GitHub Desktop.
Save dingo-d/d917ddebd65be700fbcb to your computer and use it in GitHub Desktop.
A javascript that triggers on menu page. Load only on nav-menus.php page
jQuery(document).ready(function($) {
"use strict";
$(document).on('change', '.megamenu select', function(){
var $this = $(this);
$this.next().val( $this.val() );
});
$('.megamenu select').each(function(){
var $this = $(this);
var selected = $this.next().val();
var option_length = $this.find('option').length;
for (var i = 0; i < option_length; i++) {
if ($($this.find('option')[i]).val() == selected) {
$($this.find('option')[i]).attr('selected', 'selected');
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment