有可能在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);
}`
$("#butt").click(function(){alert(1)});
是否能正常工作。 - Mostafa Shahverdy