Title: JavaScript/jQuery toggle not working
Last modified: August 31, 2016

---

# JavaScript/jQuery toggle not working

 *  Resolved [amandathewebdev](https://wordpress.org/support/users/amandathewebdev/)
 * (@amandathewebdev)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/javascriptjquery-toggle-not-working/)
 * Hi all,
 * I’m hoping someone can give me advice on this. I have a JavaScript function that
   used to work, and now it doesn’t. On this page: [http://www.nfe-lifts.com/inventory/](http://www.nfe-lifts.com/inventory/)
   when you check “Advanced Search”, a hidden div is supposed to show.
 * Here is the function:
 *     ```
       $('#advanced-options').on('change', function() {
   
          $.cookie('advanced-search', $(this).is(':checked')?'1':'0');
   
          if($(this).is(':checked')) {
              $('#advanced-div').show();
          } else {
   
              $('#advanced-div').hide('slow');
   
          }
   
          if($.cookie('advanced-search') == '1') {
   
               $('#advanced-options').prop('checked', true).trigger('change');
   
          }
        });
       ```
   
 * I’m on WP Engine and recently learned that they block certain cookies. They assured
   me that’s not what’s happening here. I’m not sure why this isn’t working. Any
   help would be appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/javascriptjquery-toggle-not-working/#post-7352948)
 * I see this in my web console when I view your page: `Error: Syntax error, unrecognized
   expression: a[href=#undefined]`
 * This causes scripts to stop working, so there isn’t any problem with what you
   posted, other than it no longer executes due to the error. A LOT of plugins and
   themes are getting this error after upgrading to WP v4.5. The code was wrong 
   all along, but the latest version of jQuery shipped with 4.5 finally started 
   enforcing proper syntax.
 * The expression should be `a[href="#undefined"]`
 *  Thread Starter [amandathewebdev](https://wordpress.org/support/users/amandathewebdev/)
 * (@amandathewebdev)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/javascriptjquery-toggle-not-working/#post-7353017)
 * Thanks for the reply. I see that error is occurring in the jquery that’s included
   in WordPress core, which I can’t touch. So how could I fix it?
 * Or maybe it’s happening in this bit of code here, but when I update with double
   quotations, it doesn’t work:
 *     ```
       $('a[href=#'+fancybox_id+']').fancybox().trigger('click');
   
       	alert($('a[href=#'+fancybox_id+']').length)
       ```
   
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [10 years, 1 month ago](https://wordpress.org/support/topic/javascriptjquery-toggle-not-working/#post-7353018)
 * It should be this:
 *     ```
       $('a[href="#' + fancybox_id + '"]').fancybox().trigger('click');
       ```
   
 *  Thread Starter [amandathewebdev](https://wordpress.org/support/users/amandathewebdev/)
 * (@amandathewebdev)
 * [10 years ago](https://wordpress.org/support/topic/javascriptjquery-toggle-not-working/#post-7353025)
 * Andrew, that was it! Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘JavaScript/jQuery toggle not working’ is closed to new replies.

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [jquery](https://wordpress.org/support/topic-tag/jquery/)
 * [toggle](https://wordpress.org/support/topic-tag/toggle/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 4 replies
 * 3 participants
 * Last reply from: [amandathewebdev](https://wordpress.org/support/users/amandathewebdev/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/javascriptjquery-toggle-not-working/#post-7353025)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
