PhoneGAP 中是否可以有一个 CSS 切换按钮?我想要一个按钮,如果单击它会改变颜色,再次单击时它必须返回默认颜色。知道怎么做吗?
我已经编辑了我的帖子,你们可以很容易地帮助我,因为现在我真的很困惑如何做到这一点,简单的东西但是技巧。
`This the function
function toggle(ths) {
//CSS color
$(ths).toggleClass("btnColor");
$("#tb").toggleClass("btnColorR")
//Get value clicked
var clicked = $(ths).val();
//diplay on web-page
$("#lblType").html(clicked);
$("#setCount").html(" minutes : " + minutes + " seconds : " + seconds);
//duration time count
seconds = seconds + 1;
if (seconds % 60 == 0) {
minutes += 1;
seconds = 0;
}
timer = setTimeout("toggle()", 1000);
}
The CSS
.btnColor
{
background-color:blue;
color:white;
}
.btnColorR {
background-color:green;
}
This is how my buttons are created.
function createButtons(tbID, tbClass, tbType, tbValue, onClick) {
return '\n<input '
+ (tbID ? ' id=\'' + tbID + '\'' : '')
+ (tbClass ? ' class=\'' + tbClass + '\'' : '')
+ (tbType ? ' type=\'' + tbType + '\'' : '')
+ (tbValue ? ' value=\'' + tbValue + '\'' : '')
+ (onClick ? ' onclick=\'toggle(this);' + onClick + '\'' : '')
+ '>';
}
function DisplayButtons(cableData) {
var newContent = '';
$.each(cableData,
function (i, item) {
newContent += createButtons("tb" + item.CommonCable, null, "submit", item.CommonCable, toggle);
});
$("#planned").html(newContent);
}`