Uncaught TypeError: Object # has no method ‘toggle’ – jQuery

Ran into a bit of a problem with jQuery today, not entirely sure what the issue was but apparently it did not like me using the .get() function. I received the following error:

//Enable toggling of sub_order display
$(document).ready(function() {
    $('.expanding_header').click(function(){
      $(this).find('.expanding_content').get(0).toggle('slow', function() {
      });
    });
});
Uncaught TypeError: Object # has no method ‘toggle’

By substituting the get function with a :first selector the error does not occur:

$(document).ready(function() {
    $('.expanding_header').click(function(){
      $(this).find('.expanding_content:first').toggle('slow', function() {
      });
    });
});

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s