CodeClerks

jQuery: Change the value of an input



Write the reason you're deleting this FAQ

jQuery: Change the value of an input

How can I change the value of a form input using only jQuery/Javascript? This is what my form looks like:

<form name="submit" id="submit">
<input type="hidden" name="changevalue" id="changevalue" value="0">
 

I want to execute jQuery that changes "changevalue" to 1 at a certain event.

Comments

Please login or sign up to leave a comment

Join
Drake83
I found the answer. Fairly easy. jQuery: Change the value of an input

$("#changevalue").val('1');


This will change the value of the input changevalue to 1.



Are you sure you want to delete this post?

jakemadness

//Javascript
document.getElementById("changevalue").value = "new value";

//Jquery

//Method #1
$('#changevalue').val('new value');

//Method #2
$('input[type=hidden]#changevalue').val('new value');
 



Are you sure you want to delete this post?