Advertisement
zviryatko

Wordpress add toggle element to mobile menu

Jan 22nd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Add element to open submenus for mobile.
  3.  */
  4. (function($) {
  5.   $(document).ready(function() {
  6.     $('nav.mobile_menu > ul > li.has_sub').each(function() {
  7.       var $submenu = $(this).children('.sub_menu');
  8.       var $link = $(this).children('a');
  9.       var $open = $('<span class="open">&gt;</span>');
  10.       $open.css({
  11.         display: 'inline-block',
  12.         float: 'right',
  13.         height: '26px',
  14.         padding: '10px 0px',
  15.         width: '46px',
  16.         'z-index': '100',
  17.         position: 'absolute',
  18.         right: '0px',
  19.         cursor: 'pointer',
  20.         'text-align': 'center'
  21.       });
  22.       $open.click(function() {
  23.         $submenu.toggle();
  24.       });
  25.       $open.insertBefore($link);
  26.     });
  27.   });
  28. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement