Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道该怎么做:
如何使用 AJAX 替换 Rails 3 中的 div?
但是,虽然这会替换 div 的内容,但它不会更改 div 的 id 值。
如何更改 div 的 id(及其内容)?
只需id为 div 设置属性:
id
$("#your_div").html(...); # here you set div content $("#your_div").attr("id", "new_id"); #the div now has new_id id