Take the 2-minute tour ×

Complete newbie working with jQuery and am having a bit of a problem.

I have a table with some of the cells having a in them (never more than one select per cell).

In the following code select is the element that was passed to the function. I'm trying to get the parent so that I can remove the and replace it with some html.

function submit_pick( select ) {
    var parent = select.parent().get(0);      

select.remove(); works as expected

jQuery("#testdiv").html(parent.tagName); also works as expected producing TD

parent.html(parent.tagName); does not work. Firefox's web console gives an error parent.html is not a function.

share|improve this question
Just a suggestion: you might want to avoid using variable names that are also HTML tag names and JQuery function names (select, parent)... if nothing else it makes reading your code a bit confusing. :| –  McGarnagle Apr 25 '12 at 3:49
Thanks, I'll keep the naming conventions in mind for easier readability. –  Joe_Schmoe Apr 25 '12 at 4:03

5 Answers 5

up vote 0 down vote accepted

.get(0) returns a native DOMElement and not jQuery object anymore, thus you need to wrap the parent inside $() (also the reason why html() is complained as not being a function, as html() belongs to jQuery object, not DOMElement):

share|improve this answer


share|improve this answer

parent is not a jQuery object anymore, you would have to use:

share|improve this answer

get returns a dom element not a jquery object. try

var parent = select.parent().eq(0);      

eq gives you the jquery object at the index, which is what you wanted

share|improve this answer

This is because you have done .get(0) which returns a DOM element, not a jquery object.


you should use jQuery(parent) to be able to use the .html() method again.

share|improve this answer

Your Answer


