Welcome to WebmasterWorld Guest from 126.96.36.199 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
Remove id attribute ocon msg:4454145 2:11 pm on May 16, 2012 (gmt 0) If I have <div id="name1"> I can change the id to something else using: <script> document.getElementById("name1").id="name2"; </script> What can I do if I just want to remove the id and just have <div>? Would I use: <script> document.getElementById("name1").id=""; </script> Or would that just set the div to <div id="">?
Fotiman msg:4454148 2:28 pm on May 16, 2012 (gmt 0)
document.getElementById("name1").removeAttribute("id"); Setting id to an empty string will not remove the attribute. You can verify this by using browser tools like Firebug or Chrome's Developer Tool to inspect the element and you'll still see an empty id attribute defined. ocon msg:4454184 3:37 pm on May 16, 2012 (gmt 0)