如何使用jquery将文本框值转换为标签 [英] how to get textbox value into label using jquery

查看:110
本文介绍了如何使用jquery将文本框值转换为标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用jquery单击按钮时,如何将textbox的值设置为标签。

How can I get the value of textbox into label when I click on a button using jquery.

我知道如何在jquery中编写click事件。但是当我写下像

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'

请帮助

推荐答案

$('#labelID').html ( $('#textboxID').val() );

jQuery中的val / html方法充当getter和setter。如果将值传递给它们,则它们会将元素的值/ html设置为传递的值。如果你只是调用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.

这篇关于如何使用jquery将文本框值转换为标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆