I currently calculate a random value with jQuery and save it to a variable.
I want this variable to be the value of:
<input type="text" class="mastery_num" name="mastery_num" id="mastery_num" value="VALUE_FROM_JQUERY"></input>
How can I do this?
You're looking for val:
var your_variable = doMyCalculation();
$("#mastery_num").val(your_variable);
$("#mastery_num").val(your_saved_variable);
.val() is jQuery's equivalent of the plain JavaScript .value property. .val() either returns or sets the value depending on whether you supply a value to it.
Plain JavaScript version, for future viewers:
document.getElementById("mastery_num").value = your_saved_variable;