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