jquery - How do I make permanent changes to javascript variables or html elements inside of .click()? -
for example:
$(document).ready(function(){ $('#submit').click(function(){ $('#rightad').text("hello everybody"); }); }); this changes text in #rightad moment button clicked. how make remain, "hello everybody" after click ends? or thinking wrong way?
changing via script reflect until page gets refreshed.
try this:
html:
<div id="rightad"> text.....</div> <button id="submit">submit</button> jquery:
$('#submit').click(function(){ $('#rightad').text("hello everybody"); }); if using <input type="submit"/> submit page, changes flashed page gets refresh.
use event.preventdefault() prevent form submission
Comments
Post a Comment