【问题标题】:PhoneGap Android Tap & Hold event [duplicate]PhoneGap Android点击并按住事件[重复]
【发布时间】:2012-03-24 12:41:30
【问题描述】:

电话间隙或 jquery 中是否有一个功能,这意味着我可以获取元素上的任何点击并按住事件。我查看了 phonegap 文档,但找不到任何东西

我看到 jQuery mobile 有它,但我目前没有包含它,我希望我不需要为此添加另一个库

谢谢

【问题讨论】:

    标签: javascript jquery android cordova


    【解决方案1】:

    在这里你可以做同样的事情。我已经在我的项目中尝试过

    <!DOCTYPE html>
    <html>
    <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <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.3.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
    <script>
    $(document).on("pagecreate","#pageone",function(){
      $("p").on("taphold",function(){
        $(this).hide();
      });                       
    });
    </script>
    </head>
    <body>
    
    <div data-role="page" id="pageone">
      <div data-role="header">
        <h1>The taphold Event</h1>
      </div>
    
      <div data-role="main" class="ui-content">
        <p>If you tap and hold me for one second, I will disappear.</p>
        <p>Tap and hold me!</p>
        <p>Tap and hold me too!</p>
      </div>
    
      <div data-role="footer">
        <h1>Footer Text</h1>
      </div>
    </div> 
    
    </body>
    </html>
    

    http://www.w3schools.com/jquerymobile/tryit.asp?filename=tryjqmob_event_taphold

    【讨论】:

    • 单独的代码块并不能提供好的答案。请添加解释(为什么它解决了问题,错误在哪里等等......)
    • 试图理解你对“在这里你可以做同样的事情”的意思。请解释您对这段代码的建议。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-29
    • 2011-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-30
    相关资源
    最近更新 更多