没有反应从我的HTML按钮在phonegap [英] No reaction from my HTML buttons in phonegap

查看:119
本文介绍了没有反应从我的HTML按钮在phonegap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个HTML按钮,当我点击他们没有外部光芒,他们不做任何事情。

I have three HTML buttons and when I click on them there is no outer glow and they don't do anything.

我也试图风格他们,他们保持默认设计。我只是使用普通的代码我只是没有一个线索他们的错误

I have also tryed to style them but they stay with the default design. I have just used ordinary code I just don't have a clue what's wrong with them

<input type="button" value="Proceed">
<input type="button" value="Cancel">


推荐答案

不要使用,你的按钮,让他们反应触摸。

Don't use , instead use with CSS to create your buttons so they react to touch. It'll require some javascript as even most mobile browsers don't properly map touch events to the CSS :active pseudoclass.

您的按钮:

<a class="button" id="yourButton">Button</a>

触摸时切换背景和文字颜色的一些非常基本的CSS:

Some very basic CSS to toggle the background and text color on touch:

a.button {
    color:#fff;
    border:0px;
    padding:5px;
    background:#000;
}

a.button-active {
    background:#fff;
    color:#000;
}

这里是你在你的onload on deviceready处理函数中调用的javascript。我在这里使用xuijs(xuijs.com),但是你可以使用jQuery或任何其他javascript来添加和删除类:

And here's the javascript you would call in your onload on deviceready handler. I'm using xuijs here (xuijs.com), but you can use jQuery or any other javascript to add and remove classes:

x$('.button').on('touchstart', function(e) { 
    x$(e.currentTarget).addClass('button-active'); 
} );
x$('.button').on('touchend', function(e) { 
    x$(e.currentTarget).removeClass('button-active'); 
} );

这是一个非常基本的例子。一旦你进行了所有设置,你可以对CSS进行任何更改,以确定按钮将处于活动状态和非活动状态时的外观。

This is a very basic example. Once you have this all setup, you can make any changes you want to the CSS to determine how the button will look when it is active and inactive.

这篇关于没有反应从我的HTML按钮在phonegap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆