小白教程
所有教程
关于
Search
172.71.254.45
172.71.254.45
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Event mouseup”的源代码
本页内容
上一节:
Event_mouseover
下一节:
Event_off
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:mouseup()}}[[Category:jquery ref events|43]] = jQuery mouseup() 方法 = [[jquery ref events|jQuery 事件方法]] 在 <div> 元素上松开鼠标左键,插入一些文本: <sample title="" desc="" lang="html" hererun="1"> $("div").mouseup(function(){ $(this).after("释放鼠标按钮。"); }); </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(){ $("div").mouseup(function(){ $(this).after("<p style='color:green;'>释放鼠标按钮。</p>"); }); $("div").mousedown(function(){ $(this).after("<p style='color:purple;'>按下鼠标按钮。</p>"); }); }); </script> </head> <body> <div>在这个 div 元素中按下和释放鼠标按钮。</div> </body> </html> </run> == 定义和用法 == 当鼠标指针移动到元素上方,并松开鼠标左键时,会发生 mouseup 事件。 mouseup() 方法触发 mouseup 事件,或添加当发生 mouseup 事件时运行的函数。 '''提示:'''该方法通常与 [[event mousedown|mousedown()]] 方法一起使用。 == 语法 == 触发被选元素的 mouseup 事件: $(selector).mouseup() <run name=""> <!DOCTYPE html> <html> <head> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").mouseup(function(){ $("p").slideToggle(); }); $("div").mouseover(function(){ $("button").mouseup(); }); }); </script> </head> <body> <p>This is a paragraph.</p> <button>Toggle</button><br><br> <div>Mouse over this text to trigger the mouseup event for the button above.</div> </body> </html> </run> 添加函数到 mouseup 事件: $(selector).mouseup(function) <run name=""> <!DOCTYPE html> <html> <head> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("div").mouseup(function(){ $(this).after("<p>Mouse button released.</p>"); }); }); </script> </head> <body> <div style="color:red;">Release the mouse button over this div element.</div> </body> </html> </run> {| class="table table-striped table-hover" ! 参数 ! 描述 |- | function | 可选。规定 mouseup 事件触发时运行的函数。 |} [[jquery ref events|jQuery 事件方法]]
返回至“
Event mouseup
”。
上一节:
Event_mouseover
下一节:
Event_off