0

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)?

Community
  • 1
  • 1
wachichornia
  • 1,178
  • 14
  • 31
  • Have you read up on JavaScript or jQuery? – JD. Aug 03 '12 at 14:00
  • Some. I'm working with dinamycally generated divs, and right now I'm just hiding the ancient div and showing the new one. I don't know if this is the best method, hence my question. – wachichornia Aug 03 '12 at 14:17

1 Answers1

3

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
dimuch
  • 12,728
  • 2
  • 39
  • 23