jQuery select() method triggers when a text in the text field or text area is selected. This method attaches a handler, which executes when the selected event is fired.

当在文本字段或文本区域中选择文本时, jQuery select()方法触发。 此方法附加一个处理程序,该处理程序在激发选定事件时执行。

The syntax for using jQuery select():

使用jQuery select()的语法:

  • select()选择()

This signature is used without any arguments

使用此签名时不带任何参数

  • select (handler)选择(处理程序)

The handler is a function, which is executed when the text inside the <text area> or <input type=”text”> gets selected.

处理程序是一个函数,当选择<文本区域>或<输入类型=“文本”>中的文本时执行。

jQuery select()函数示例 (jQuery select() function example)

Following example demonstrates select() method usage.

下面的示例演示select()方法的用法。

jquery-select.html

jquery-select.html

<!DOCTYPE html>
<html>
<head>
<title>jQuery Select</title>
<script src="https://code.jquery.com/jquery-2.1.1.js"></script><style>
p {color: green;
}
div {
color: red;
}
</style></head>
<body>
<p>Select Event Demo </p>
<input type="text" value="Select this text">
<div></div>
<script>
$( ":input" ).select(function() {
$( "div" ).text( "You have selected the text." ).show().fadeOut( 1500 );
});
</script>
</body>
</html>

In this example, you can see that the select() method is triggered when you select the text in the input field. When you select the text, the function attached to the select() method is executed and a text is displayed below the input field and fades out. This is how select() method works in the jquery.

在此示例中,您可以看到在输入字段中选择文本时触发了select()方法。 选择文本时,将执行附加到select()方法的函数,并且文本将在输入字段下方显示并逐渐消失 。 这就是select()方法在jquery中的工作方式。

You can try it yourself by selecting the text in the below text box.

您可以通过在下面的文本框中选择文本来自己尝试。

演示地址

翻译自: https://www.journaldev.com/5024/jquery-select-text-event-function-select-method

jQuery选择文本事件函数– select()方法相关推荐

  1. jquery中阻止事件冒泡的方法

    2019独角兽企业重金招聘Python工程师标准>>> 根据<jquery基础教程> 第一种方法:判断事件的"直接"目标是否是自身,如果不是自身,不予 ...

  2. 使用JQuery选择HTML遍历函数

    使用JQuery,可以很容易的选择THML元素.但在有些时候,HTML结构比较复杂的时候,提炼我们选择的元素就是一件比较麻烦的事情. 1.children 这个函数得到一组元素的直接子级. 给chil ...

  3. jquery概述_jQuery事件方法概述

    jquery概述 jQuery API provides different event methods to interact with the browser. jQuery event meth ...

  4. 锋利的Jquery【读书笔记】 -- 第四章 jQuery中的事件和动画

    锋利的Jquery读书笔记 第三章 jQuery中的DOM操作 jQuery中的事件 事件绑定 bind方法 合成事件 hover方法 toggle方法 事件冒泡 事件对象 停止事件冒泡 阻止默认行为 ...

  5. JavaScript--函数--参数--事件函数的关系--形参和实参

    函数 概念:函数就是代码块,可以多次调用,很容易实现模块化编程. 好处: 1)减少代码开发时间 2) 模块化编程 3) 可以重复使用 函数的定义: 形式1 function fn(){ // 函数体内 ...

  6. 深入学习jQuery描述文本内容的3个方法

    前面的话 在javascript中,描述元素内容有5个属性,分别是innerHTML.outerHTML.innerText.outerText和textContent.这5个属性各自有各自的功能,且 ...

  7. JQuery框架2.位置属性|筛选方法|事件

    1.位置属性 jquery的css position获取匹配元素相对父元素的偏移位置:offset获取匹配元素在当前视口的相对偏移,返回的对象包含两个整型属性:top 和 left $("p ...

  8. 获得焦点时选择文本框的所有内容(Vanilla JS或jQuery)

    本文翻译自:Select all contents of textbox when it receives focus (Vanilla JS or jQuery) 什么是Vanilla JS或jQu ...

  9. jQuery1.9+ 废弃的函数和方法 升级Jquery版本遇到的问题

    面临问题 很久没关注JQuery了,今天突然想升级一下系统中使用的jquery版本,突然发现,升级JQuery版本到1.9之后出现了很多问题,比如:$.browser is undefined.突然就 ...

最新文章

  1. LLC 逻辑链路控制
  2. Spring AOP 面向切面编程相关注解
  3. Json返回时间中出现乱码问题的两种解决方法
  4. 转: Linux 下修改oracle 的字符集:WE8ISO8859P1 修改为 ZHS16GBK
  5. 服务器内存超限问题_服务器内存爆满最佳处置方案
  6. 注意力机制Attention Model(mechanism) 的 套路
  7. matlab mysvd代码解释,关于使用SVD进行PCA主成分提取的代码问题!也是必须涉及到原理的!...
  8. 003::每天五分钟入门TCP/IP协议栈::IP协议之TOS字段说明
  9. JAVA win10 JDK环境配置(内含JDK,eclipse安装包)
  10. 常见视频编码格式解析
  11. Office2007 三合一绿色精简版
  12. 双侧检验的p值和单侧检验_t检验的时候怎么区分是单侧检验还是双侧呢?
  13. 物来顺应,未来不迎,当时不杂,既过不恋
  14. 给俺的女神翠花发邮件告白,我学会了这些网络基础知识
  15. 基于Ant Design vue框架之三 删除功能细分
  16. UVA1665 Islands (并查集)
  17. PPC关键字广告是什么?一次搞懂CPC、CPM广告投放术语
  18. h5页面键盘弹出影响页面布局(兼容)
  19. G120变频器本地_远程切换(CDS切换)的具体方法和步骤
  20. 六轴EtherCAT总线伺服涂布收卷机程序,采用六个伺服+变频器+编码器,动态测量频率

热门文章

  1. ACM PKU 1019 Number Sequence http://acm.pku.edu.cn/JudgeOnline/problem?id=1019
  2. Spring的@Transactional事务注意事项
  3. 【laravel5.4】使用baum\node 类库实现无限极分类
  4. selenium——元素的定位
  5. 股灾情形下搞了个满堂红,我也是醉了
  6. 【Linux】【Services】【Package】编译安装
  7. EasyUI文档学习心得
  8. 在Excel中插入Flash及解决不能自动播放问题
  9. caffe---之eltwise层
  10. 自动驾驶算法-滤波器系列(五)——高级运动模型在UKF中的应用