Reputation: 39
How to set/change input value on other div click? Input type is hidden. It is possible?
Upvotes: 0
Views: 1202
Reputation: 87073
$('#your_div').on('click', function() {
$('#hidden_input').val('some_val');
});
Here your_div
points to id
of your div
and hidden_input
is the id
of hidden field. You use can any valid jQuery selectors for them.
Upvotes: 5
Reputation: 3200
Its no, problem:
$(document).ready(function() {
$('#div').click( function() {
$('#input').val('value');
});
});
Remember, you can work on hidden
or display: none
elements like they are visible.
Upvotes: 0
Reputation: 34107
Working demo http://jsfiddle.net/aqrvA/5/ OR http://jsfiddle.net/aqrvA/1/
API: http://api.jquery.com/val/
Hope this helps
code
$("#iron").click(function() {
alert("Before Change ==> " + $("#hulk").val());
$("#hulk").val("IRONMAN");
alert("After Change ==> " + $("#hulk").val());
});
Upvotes: 0
Reputation: 908
$('#div_to_click').click(function(){
$('#hidden_input').val('input_value');
});
Hope it helps :-)
Upvotes: 0
Reputation: 19252
$("#target").click(function() {
$('#hiddedID').val('Some Value');
});
Upvotes: 1