tags:

views:

179

answers:

3

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

+3  A: 
$('#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.

Jan Hančič
+1  A: 
$('#labelID').html($('#textboxID').val());
jmein
A: 
$('#labelID').html($('#textboxID').val());
dasilvj