使用 .select() 取消选择在输入中选择的内容 [英] Unselect what was selected in an input with .select()

查看:30
本文介绍了使用 .select() 取消选择在输入中选择的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 .select() 选择输入框中的文本后,我做了以下操作:

HTML:

jQuery:

$(".hoverAble").mouseenter(function() {this.select();}).mouseleave(function() {//我不知道该放什么.});

请参阅

http://jsfiddle.net/robert/adCfw/6/

After I use .select() to select the text in the input box when hovered over I did the following:

HTML:

<input type="text" class="hoverAble" value="hover here"/><br />

jQuery:

$(".hoverAble").mouseenter(function() {

    this.select();

}).mouseleave(function() {

    //I can't figure what to put here.
});

See here. Warning for it to function correctly (in jsfiddle) you must click once in the result frame.

The main idea is mouseleave is working as as expected also.

As you might have noticed, I can't figure out a way to un-select the text when you hover out and avoid this:

解决方案

use .blur();

http://jsfiddle.net/robert/adCfw/6/

这篇关于使用 .select() 取消选择在输入中选择的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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