jquery - How to keep a value unchanged? -



jquery - How to keep a value unchanged? -

this basic question, but...

<div id="caption">323</div> var = $("#caption").html();

now, content of #caption changed...

and need starting value (323)

alert (a);

but result new value.

how can maintain starting value unchanged ?

var old=$('#caption').html(); $('#sub').on('click',function(){ $('#caption').html('525'); alert(old); });

demo

jquery

Comments