Reputation: 33
How can I get the value of textbox into label when I click on a button using jquery.
I know how to write the click event in jquery. But when I write something like
$('#labelID').val() = $('#textboxID').val();
I get an error saying 'cannot assign to a function result'
Please help
Upvotes: 2
Views: 11899
Reputation: 430
var value = $("#textbox1").val();
$("#label1").html(value);
return false;
Upvotes: 0
Reputation: 53931
$('#labelID').html ( $('#textboxID').val() );
val/html methods in jQuery act as getters and as setters. If you pass a value to them then they will set the value/html of the element to the passed value. If you just call val() you will get the value of the element.
Upvotes: 8