Advertisement
srikat

Untitled

Sep 18th, 2014
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.89 KB | None | 0 0
  1. jQuery(document).ready(function($) {
  2.  
  3.     // Show/hide the search box at mobile widths
  4.     $('.search-toggle').click(function() {
  5.         // var target = $(this).parent().children('.nav-primary');
  6.         var target = $('.site-header .widget_search');
  7.         $(target).slideToggle('fast', function() {
  8.             return false;
  9.             // Animation complete.
  10.         });
  11.  
  12.         var bg = $(this).css('background-image');
  13.         bg = bg.replace('url(','').replace(')','');
  14.  
  15.         if (bg == '"http://utulsa.dev/wp-content/themes/utulsa/images/search.png"') {
  16.             bg = 'url(http://utulsa.dev/wp-content/themes/utulsa/images/close.png)';
  17.         }
  18.         else {
  19.             bg = 'url(http://utulsa.dev/wp-content/themes/utulsa/images/search.png)';
  20.         }
  21.  
  22.         $(this).css('background-image',bg);
  23.     });
  24.     // Stop the navigation link moving to the anchor (Still need the anchor for semantic markup)
  25.     $('.search-toggle').click(function(e) {
  26.         e.preventDefault();
  27.     });
  28.  
  29. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement