Trying to insert html code into running html then after being processed remove said code. This is what I have written and don't understand why it won't work. Shouldn't the quotes run it as a string to be into put into the div span?
<div><span id="evolutionUpgrades"></span></div>
var membrane = "bubble";
function evolutionUpgrade() {
if (membrane == "bubble") {
if (evolution >= 1) {
document.getElementById("evolutionUpgrades").innerHTML =
'<p style="color:blue" title="Choose your evolution carefully.">Evolutions</p> <
<p title="Your p title = "Your first evolution. Double wall bubbles were the first evolution of cells."><button" type="button"> onclick="doublebubble< button type = "button"
onclick = "doublebubble()"><b>Double" Bubble<> < b > Double Bubble < /b></button><button > < /p>'
}
}
};
function doublebubble() {
membrane = "doublebubble"
document.getElementById('membrane').innerHTML = "Double Bubble";
}
This should fire when the evolution variable becomes equal to or greater than 1 and run the two if functions and then copy paste the code into the html.
Unfortunately it seems my javascript is ignoring the '' as a string and trying to run the code as is.
How do I make it just insert so that while the if statements are true it creates a button that than performs the function when clicked and on running that function becomes untrue to then be removed?
Am I using the wrong flag? The wrong punctuation? What am I doing wrong or not know? Please help fix this. Please be detailed with your answer so I can learn from it. Just fixing my code without explaining does't truly help me.
I don't mind people fixing my grammar mistakes. But please don't change the code. I need to see the differences between broken and fixed to learn. Especially when you break the code. My code was correct except for the Jason W's fix.