【问题标题】:Swap background images on touch using phonegap?使用phonegap在触摸时交换背景图像?
【发布时间】:2012-10-09 19:16:24
【问题描述】:

使用 phonegap 开发移动应用程序,我面临一个小问题。当触摸按下我的任何按钮时,我想在触摸期间交换背景,以便向用户提供正在发生的事情的视觉反馈。

但是除了onclick和onmouseup之外,android中的onmousedown事件或任何其他事件都不会触发?我怎样才能做到这一点?

我有我的 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>

谢谢

【问题讨论】:

    标签: javascript android html cordova


    【解决方案1】:

    试试 ontouchstart 和 ontouchend

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

    并查看警报是否触发。

    【讨论】:

    • 太棒了!我正在使用 ISCROLL 研究一些疯狂的解决方法。非常感谢!只是出于好奇,您是否在某处记录了所有可用的事件?我找不到对 ontouchstart/end 的任何引用。我开始使用 javascript!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多