<!DOCTYPE html>
<html>
<body>
<div id="foo"></div>
<script type='text/javascript'>
var obj = document.getElementById("foo");
obj.id = "rar";
console.log(obj.id);
console.log(document.getElementById("rar").id);
</script>
</body>
</html>