0

phonegap を使用してモバイル アプリを開発しているときに、小さな問題に直面しています。タッチがボタンのいずれかを押すと、タッチ中に背景を交換して、ユーザーに何が起こっているかを視覚的にフィードバックできるようにします。

しかし、onmousedown イベントは、onclick と onmouseup を除いて、Android やその他のイベントで発生することはありませんか? どうすればそれを達成できますか?

機能する背景を交換するJavaScriptメソッドがあります。

function touched(isTouched){
                console.log(isTouched);
                if (isTouched) {
                    $('.blue_cell.firstCell').css("background-image", "url(images/cells/list-cell.png)");                   
                } else {
                    $('.blue_cell.firstCell').css("background-image", "url(images/cells/blue-cell.png)");
                }

            }

そして、使用してみたイベントを含むテストボタンがあります:

<div class='blue_cell firstCell'  onmouseup="touched(false)" onmousedown="touched(true)"
        onmouseover="touched(true)" onfocusin="touched(true)">
    <div class='cellMainText'>openPopOver()</div>
    <div class='cellIconText'>POP</div></div>

ありがとう

4

1 に答える 1

1

ontouchstart と ontouchend を試す

<div class='blue_cell firstCell' ontouchstart="javascript:alert()" ontouchend="javascript:alert()">

アラートが発生するかどうかを確認します。

于 2012-10-09T11:16:24.620 に答える