jQuery在不使用插件的情况下获取输入字段中突出显示的字符的值 [英] jQuery get value of Highlighted characters in input field without using plugin

查看:75
本文介绍了jQuery在不使用插件的情况下获取输入字段中突出显示的字符的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道jQuery具有.select();方法,问题是我可以获取此选择的值吗?!

I know that jQuery has .select(); method , the question is can I get the value of this selection ?!

http://api.jquery.com/select/

我只需要获取文本或输入框内突出显示的字符的值.

Simply i need to get the value of Highlighted characters inside text or input box.

不使用任何插件.

推荐答案

HTML

<input type="text" name="textbox1" />

jquery

$(document).ready(function(){
    $('input[type="text"]').select(function() {
        alert(window.getSelection());
    });
});

这篇关于jQuery在不使用插件的情况下获取输入字段中突出显示的字符的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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