Odyss3us
Odyss3us

Reputation: 6635

jQuery .after() not working in IE

I am trying to add a table row to a table using .after() but it's not working in any IE, I keep getting this error "Object required" and the error seems to be coming from line 5151 in my jQuery library.

Here is my code:

$('#view').live('click',function(){
    var parent = $(this).parent();
    parent.after("<tr><td>Test</td></tr>"); 
});

Any ideas?

Upvotes: 1

Views: 4456

Answers (3)

shybovycha
shybovycha

Reputation: 12245

Works fine for me in IE, FF and Chrome: demo.

Upvotes: 0

Hogsmill
Hogsmill

Reputation: 1574

I would definitely validate your HTML first; this kind of thing often fails beacuse IE is less "generous" when things aren't valid.

Do you know what parent is? is it definitely a tr?

Upvotes: 0

Guffa
Guffa

Reputation: 700362

A likely reason is that the HTML code isn't valid without a table tag.

Create the elements as separate elements instead:

parent.after($('<tr/>').append($('<td/>').text('Test')));

Upvotes: 2

Related Questions