我们先来看一下select()的基本语法
$(selector).select(function)
function是可选的。表示当发生 select 事件时运行的函数。
下面我们来看具体示例
<!DOCTYPE html>
<html>
 <head>
 <meta charset="utf-8">
 <title></title>
 <script type="text/javascript" src="http://code.jquery.com/jquery-3.1.0.min.js"></script>
 <script type="text/javascript">
$(document).ready(function(){
 $("input").select(function(){
 $("input").after("文本标记!");
 });
 $("button").click(function(){
 $("input").select();
 }); 
});
</script>
 </head>
 <body>
<input type="text" name="FirstName" value="Hello World" />
<br>
<button>触发输入域中的select 事件</button>
</body>
</html>运行效果如下
当选中输入域中的文本“Hello World"时,会触发事件,效果如下
当点击按钮也会触发输入域中的select事件,效果与上述相同。
本篇文章到这里就全部结束了,更多精彩内容大家可以关注Gxl网的其他相关栏目教程!!!
Copyright © 2019- huatuo0.cn 版权所有 湘ICP备2023017654号-2
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务