I am trying to update the <p> tag using jquery, however, when I click the ‘submit’ button the text I am inserting with innerHTML quickly disappears. UNLESS I use Firefox, in which case it seems to work -IF- I insert the alert box. This sounds to me like some sort of timing problem. But I am not sure quite what it is or how do fix it. Does anyone have an idea what the problem might be?
Thanks in advance for all the help!
$(document).ready(function(){
$('#addCourse').live("submit", function(){
//alert("Submit Function. hours = "+$('#hours').val());
document.getElementById('hrs_planned').innerHTML = 'HOURS = '+INIT_PLANNED_HRS+2;//($('#hours').val())+' GPA';
});
document.getElementById('hrs_planned').innerHTML = 'HOURS!! = '+INIT_PLANNED_HRS+' GPA';
});
and the html
<li><h3>Planned Courses</h3><p id = "hrs_planned"> gpa </p></li>
Try
return false;Also use
on()instead oflive()if you are using jQuery 1.7 aslive()has been depricated. See documentation for details.If you are using jQuery 1.6.x or earlier use
delegate()instead...or if that fails you can try to use
e.preventDefaultande.stopPropagation.