0

私はjquery mobileの初心者です。私はstackoverflowから取得したコードを使用しています。私の問題は、このソリューションはサムスンなどではうまく機能しますが、iPhoneやsonyericssonでは機能しないことです。誰か助けてください...

リンクをクリックしてページの下部をスクロールダウンしながら、ページの上部に戻りたい..

これが私のコードです:

  <a id="uptotop"  class="ui-btn-right" data-icon="arrow-u" data-theme="a">▲TOPにもどる    </a>
                     <script type="text/javascript">
    $('div').live('pagebeforecreate',function(event, ui){
      $('#uptotop').live('click',function() {
    $('html, body').animate({scrollTop: '0px'}, 800);
           });

         });
</script>  
4

1 に答える 1

0

単純なアンカーを使用するのはどうですか? 例:

<!DOCTYPE html>
<html>
  <head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Test</title>
  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
  <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
  <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>

<body>
  <div data-role="page">
    <div data-role="header">
      <h1><a name="top"></a>Header</h1>
    </div> <!-- /header -->

    <div data-role="content">
      <p>lots of content here...<br>scroll down to find the button...
        <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
        <a href="#top" target="_top" data-role="button">Back to top of page ...</a>
      </p>
    </div> <!-- /content -->
  </div> <!-- /page -->

</body>
</html>
于 2012-11-05T20:28:53.910 に答える