I know how to do this:
How to replace the div in Rails 3 using AJAX?
But while that replaces the content of the div, it doesn't change the id value of the div.
How can I change the id of the div (along with its content)?
Just set id
attribute for the div:
$("#your_div").html(...); # here you set div content
$("#your_div").attr("id", "new_id"); #the div now has new_id id