I have a div as follows:
<div><p></p></div>
Thus when I do,
var div_contents = $("div").html()
then
div_contents = "<p></p>"
However I have another function that is dynamically changing the content of the div, let’s say, to <div><h2></h2></div>
Thus, my div_contents value is changing from "<p></p>" to "<h2></h2>"
How can I keep the value of div_contents from changing so that I can use it as a final or static variable or something?
div_contentswill only change when you make an assignment. If the value ofdiv_contentsis<h2></h2>, is is because that was the state of the div when you called$("div").html(). If the div changes after that, the variable will retain its value until you make another assignment.I would need to see more of your code to see what is really going on.