如何将占位符添加到 GWT 文本输入字段 [英] How to add a placeholder to a GWT text input field

查看:34
本文介绍了如何将占位符添加到 GWT 文本输入字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道 Google Web Toolkit 文本输入小部件会在字段为空时显示一条消息?

Does any know of a Google Web Toolkit text input widget that would display a message inside the field when it is empty?

例如一个名字字段会说:输入你的名字",当用户开始输入时,标签会被删除以显示输入的文本.

E.g. a first name field that would say: 'enter your first name' and when the user starts typing the label is removed to show the typed text.

你会怎么做?

丹尼尔

推荐答案

这在 textarea 中对我有用:

This does the work for me in a textarea:

yourInputField.getElement().setPropertyString("placeholder", "enter your first name");

我认为这是一个 HTML5 功能.

I think it is a HTML5 feature.

这篇关于如何将占位符添加到 GWT 文本输入字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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