tap event
添加的版本:1.0
說明:在快速、完整的觸摸事件後觸發。
jQuery( ".selector" ).on( "tap", function( event ) { ... } )
jQuery Mobile tap
事件在單個目標對象上發生的快速、完整的觸摸事件之後觸發。它相當於標準點擊事件的手勢,在觸摸手勢的釋放狀態下觸發。
這個插件擴展了 jQuery 的內置方法。如果沒有加載 jQuery Mobile,調用 .tap()
方法可能不會直接失敗,因為該方法仍然存在。但是,不會發生預期的行為。
警告:小心使用水龍頭
Tap 使用 vclick,因此在觸摸設備上應謹慎使用。有關詳細信息,請參閱vclick API documentation。
例子:
一個簡單的捕獲和作用於點擊事件的例子
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>tap demo</title>
<link rel="stylesheet" href="//code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.css">
<script src="//code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="//code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.js"></script>
<style>
html, body { padding: 0; margin: 0; }
html, .ui-mobile, .ui-mobile body {
height: 85px;
}
.ui-mobile, .ui-mobile .ui-page {
min-height: 85px;
}
#nav {
font-size: 200%;
width:17.1875em;
margin:17px auto 0 auto;
}
#nav a {
color: #777;
border: 2px solid #777;
background-color: #ccc;
padding: 0.2em 0.6em;
text-decoration: none;
float: left;
margin-right: 0.3em;
}
#nav a:hover {
color: #999;
border-color: #999;
background: #eee;
}
#nav a.selected,
#nav a.selected:hover {
color: #0a0;
border-color: #0a0;
background: #afa;
}
div.box {
width: 3em;
height: 3em;
background-color: #108040;
}
div.box.tap {
background-color: #7ACEF4;
}
</style>
</head>
<body>
<h3>Tap the green square to see the above code applied:</h3>
<div class="box"></div>
<script>
$(function(){
$( "div.box" ).bind( "tap", tapHandler );
function tapHandler( event ){
$( event.target ).addClass( "tap" );
}
});
</script>
</body>
</html>
演示:
相關用法
- JQuery Mobile taphold用法及代碼示例
- JQuery trigger()用法及代碼示例
- JQuery toArray()用法及代碼示例
- JQuery type()用法及代碼示例
- JQuery triggerHandler()用法及代碼示例
- JQuery toggle()用法及代碼示例
- JQuery toggleClass()用法及代碼示例
- JQuery text()用法及代碼示例
- JQuery Mobile throttledresize用法及代碼示例
- JQuery trim()用法及代碼示例
- JQuery Mobile Popup initSelector用法及代碼示例
- JQuery Mobile Collapsibleset disabled用法及代碼示例
- JQuery UI Datepicker prevText用法及代碼示例
- JQuery ajaxError()用法及代碼示例
- JQuery Mobile Selectmenu defaults用法及代碼示例
- JQuery UI Tabs event用法及代碼示例
- JQuery UI Selectable appendTo用法及代碼示例
- JQuery UI :focusable Selector用法及代碼示例
- JQuery UI Selectmenu disabled用法及代碼示例
- JQuery UI Button classes用法及代碼示例
- JQuery .jquery用法及代碼示例
- JQuery .scroll()用法及代碼示例
- JQuery UI Draggable snapMode用法及代碼示例
- JQuery each()用法及代碼示例
- JQuery Mobile Toolbar hide用法及代碼示例
注:本文由純淨天空篩選整理自jquerymobile.com大神的英文原創作品 tap。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。