0

以下のコードは、jQueryMobile でボタン アクションを実装しようとしていますが、うまくいきません。どこが間違っているか教えてください。すべてHTMLファイルに書かれています。ここでコードを提供する際に問題に直面しています。これが私が試みていることです。標準の HTML 形式で、scriptタグの間に以下のコードを記述しています

$('#theButton').click(function() {
   alert('The Button has been clicked,');

});

そしてbodyタグで---

<div data-role="page">
<div data-role="content">
    <input type="button" id="theButton" name="theButton" value="The Button">
</div>

しかし、アクションは呼び出されていません。

4

1 に答える 1

0

編集:以下のコードを試してください:

<html>
<head>
<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>

<script language="javascript">

    $(function() {
     $('#theButton').on('tap click',function(event, ui) {
        alert('The Button has been clicked');
     });
    });

</script>
</head>
<body>
<div data-role="page">
<div data-role="content">
    <input type="button" id="theButton" name="theButton" value="The Button">
</div>
</div>
</body>
</html>
于 2012-12-26T06:37:59.427 に答える