EDIT:
Thanks guys – perfect! I wish I could check more than one answer, since you both gave me the right answer. Quick response!
I have the following jQuery function:
$(document).ready(function(){
$('#login_btn').click(function(){
$("#message").text("button was pushed");
});
});
It works – the text of the message div changes when I click the button. But it instantly reverts back to it’s state when loaded. So all you really see is a quick flash and then it’s gone.
I am using codeigniter. The script above is named “login_attempt” and is in a file folder named “javascript” at my project root. It is the only thing in that file. Below is the outputted html source.
<html>
<head>
<script language="javascript" src="path to jquery-1.4.min.js"></script>
<script type="text/javascript" src="path to login_attempt.js"></script>
<title>Login Page</title>
</head>
<body>
<div id="message">this will become something else</div>
<button id="login_btn">Click Me</button>
</html>
I’m just now learning jQuery, but I thought when the text was changed it was supposed to stay changed. Could someone advise me on how to make sure the change remains?
Thanks.
return false to prevent the form submit.