I want to set new id to div using its old Id?
$("#oldId").attr("id","newId");
Its not working.
简单的JS
document.getElementById("PreviousName").id="CurrentName";
Take a look at this question. Can I change the ID of an HTML element using Javascript? Make sure you re-execute your jquery function after the change. Maybe you're working on a 'cached' javascript-object, not the DOM object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.