Prakadeessh Arunachalam Prakadeessh Arunachalam - 3 months ago 8
Ruby Question

AJAX inserting a row at any position in a table

I am building a rails app and I use AJAX to populate the newly created entry in the table(in views folder).

$("#career_objective_table tr:first").after('<%= @career_objective.priority %>')

With the above code, I an able to insert it at the top.
Is there a way to insert at any position? (Like in the second row or third row) ?

Answer
$("#career_objective_table tr:nth-child(4)").after('<%= @career_objective.priority %>')

Replace 4 with any number