I’m very new to jquery, and I’m trying to make a dynamic form in the following manner (and its not working). I want the form to have an initial value of “hello” as stated in the header region.
I understand that you can do this easily with html (with the value parameter), but I have a much larger goal in mind that requires the value to be dynamic.
Anyway, I just can’t seem to get it to work, so help please. Thank you.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Logging In Test</title>
<script type = "text/javascript" src="{{ STATIC_URL }}js/jquery.js">
var value = "hello";
$('#login [name=firstname]').val(value)
</script>
</head>
<body>
<form id="login">
<input type = "text" name="firstname">
</form>
</body>
</html>
Thank you.!
use
$(document).ready();http://api.jquery.com/ready/like
to set initial values after document fully loads and DOM is created properly