javascript
window.onload=function() {
document.getElementById("next").onclick=function() {
document.getElementById("out_est_value").innerHTML=document.getElementById("est_value").value;
document.getElementById("out_int_est_value").innerHTML=document.getElementById("est_value").value*0.75;
}
}
input
<label>Estimated value of property:</label><input type="text" name="est_value" id="est_value" maxlength="30"class="required number"value=""/> <br>
output
<p> You told us the estimated value of your property is £<span class="red" id="out_est_value"></span> based on this we estimate that the initial cash offer is likely be around £<span class="red" id="out_int_est_value"></span>.<p>
Whenever possible, store objects which are found in the DOM (e.g.
getElementById(x)) or accessed by looking up properties (e.g.element.value) in a separate variable if they will be accessed multiple times (essentially “reusing” them instead of finding them again). Doing so will increase the readability and performance of your code:Also, if you are really using jQuery then embrace the convenient things it does for you (it’s really worth it!), such as finding DOM elements, adding event handlers, setting HTML contents, etc. Doing this will likely improve the maintainability of your code for yourself and other developers and help you avoid common cross-browser pitfalls: