当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


jQuery Mobile taphold用法及代码示例


当我们单击并按住元素区域时,将触发jQuery Mobile Taphold事件。我们可以将此事件用于不同目的。

用法:

jQuery( ".selector" ).on( "taphold", function( event ) {  } )

方法:首先,添加项目所需的jQuery Mobile脚本。

<link rel=”stylesheet” href=”http://code.jquery.com/mobile/1.4.5/
jquery.mobile-1.4.5.min.css” />
<script src=”http://code.jquery.com/jquery-1.11.1.min.js”>
</script>
<script src=”http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js”>
</script>

范例1:



HTML

<!DOCTYPE html> 
<html> 
  
<head> 
    <link rel="stylesheet" href= 
"http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" /> 
  
    <script src= 
        "http://code.jquery.com/jquery-1.11.1.min.js"> 
    </script> 
      
    <script src= 
"http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"> 
    </script> 
  
    <script type="text/javascript"> 
        $(document).on('taphold', 'a', function(event) { 
            console.log(event) 
        }) 
    </script> 
</head> 
  
<body> 
    <center> 
        <h1>GeeksforGeeks</h1> 
        <h4>taphold Event using jQuery Mobile</h4> 
    </center> 
    <a data-role="button" id="gfg">click</a> 
</body> 
  
</html>

输出:

范例2:

HTML

<!DOCTYPE html> 
<html> 
  
<head> 
    <link rel="stylesheet" href= 
"http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" /> 
  
    <script src= 
        "http://code.jquery.com/jquery-1.11.1.min.js"> 
    </script> 
  
    <script src= 
"http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"> 
    </script> 
  
    <script type="text/javascript"> 
        $(document).on('taphold', 'a', function() { 
            console.log('taphold event fired'); 
        }) 
    </script> 
</head> 
  
<body> 
    <center> 
        <h1>GeeksforGeeks</h1> 
        <h4>taphold Event using jQuery Mobile</h4> 
    </center> 
    <a data-role="button" id="gfg">click</a> 
</body> 
  
</html>

输出:

相关用法


注:本文由纯净天空筛选整理自taran910大神的英文原创作品 jQuery Mobile taphold Event。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。