Textarea突出重点 [英] Textarea highlight on focus

查看:62
本文介绍了Textarea突出重点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在获得焦点时在textarea中突出显示所有内容。目前,一旦获得焦点,内容将突出显示,但会立即失去它。

I'm trying to have all the contents in a textarea highlight when it gains focus. Currently, as soon as it gains focus the contents will be highlighted but it immediately loses it.

这就是我正在使用的:

<textarea onfocus="this.select()" readonly>Test</textarea>

小提琴: http://jsfiddle.net/spedwards/Mr2ja/

推荐答案

您已阻止mouseup事件,因为它在焦点设置并取消选择内容后触发

You have prevent the mouseup event as well, as it fires after the focus is set and deselects the contents

<textarea onfocus="this.select()" onmouseup="return false;" readonly="readonly">Test</textarea>

FIDDLE

这篇关于Textarea突出重点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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