How to set the div id dynamically? Here is my code:
<
First of all, you are giving the id to an element an id which is already given to some element before, that's not a right thing to do you can't have more than one id in your DOM. Anyway the code would be something like
var element = document.getElementById('q4');
element.setAttribute('id', 'q7');
if(document.getElementById('q7').innerHTML = "All is well")
alert(document.getElementById('q7').innerHTML); //to check if the new id has been set correctly
Fiddle http://jsfiddle.net/kmSHB/