小白教程
所有教程
关于
Search
172.70.127.63
172.70.127.63
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Event select”的源代码
本页内容
上一节:
Event_scroll
下一节:
Event_submit
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:select()}}[[Category:jquery ref events|51]] = jQuery select() 方法 = [[jquery ref events|jQuery 事件方法]] 当文本域中的文本被选择时,显示提示消息: <sample title="" desc="" lang="html" hererun="1"> $("input").select(function(){ alert("文本已选中!"); }); </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("input").select(function(){ alert("文本已选中!"); }); }); </script> </head> <body> <input type="text" value="www.xiaobai.wang"> <p>在输入框中选取文本</p> </body> </html> </run> == 定义和用法 == 当 textarea 或文本类型的 input 元素中的文本被选择(标记)时,会发生 select 事件。 select() 方法触发 select 事件,或规定当发生 select 事件时运行的函数。 == 语法 == 触发被选元素的 select 事件: $(selector).select() <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("input").select(function(){ $("input").after("文本已选中!"); }); $("button").click(function(){ $("input").select(); }); }); </script> </head> <body> <input type="text" value="www.xiaobai.wang"> <p>在输入框中选取文本</p> <button>触发 select 事件</button> </body> </html> </run> 添加函数到 select 事件: $(selector).select(function) <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("input").select(function(){ $("input").after("文本已选中!"); }); }); </script> </head> <body> <input type="text" value="www.xiaobai.wang"> <p>在输入框中选取文本</p> </body> </html> </run> {| class="table table-striped table-hover" ! 参数 ! 描述 |- | function | 可选。规定当 select 事件被触发时运行的函数。 |} [[jquery ref events|jQuery 事件方法]]
返回至“
Event select
”。
上一节:
Event_scroll
下一节:
Event_submit