views:

656

answers:

3

I have a simple script:

$('.expand').each(function(i){ 
var _Expand = $(this).parent();
    ExpGroupBy(_Expand);
});

Trying to pass the <tr> of all <td> with the class 'expand'

However firebug keeps popping up the Error:

'TypeError: formObj.getElementsByTagName is not a function'

Any ideas?

Thanks ^^

+4  A: 

As long as the function understands that the parameter is the jQuery object and not the DOM element itself. If the function expects a DOM element reference, you can easily do that like this...

$('.expand').each(function(i){
  var _Expand = $(this).parent();
  ExpGroupBy(_Expand[0]);  // Note the [0]
});
Josh Stodola
Works, thanks =)
path411
A: 

If ExpGroupBy expects DOM element call it as ExpGroupBy(_Expand[0])

Roman
+1  A: 

parent() returns a jQuery object. Try this instead:

$(".expand").parent().each(function() { 
    ExpGroupBy(this);
});
Matthew
Why the down vote? This works.
Matthew
Nice, in firefox this is faster then Josh Stodala's answer and will give the same result
PetersenDidIt