CSS toggle button?

cordova, css, javascript, jquery

Solution

consider that your button is `#butt`:

$("#butt").click(function(){
     $(this).toggle('red');
})

and CSS:

.red{
 color:red;
}

Problem

Is it possible to have a CSS toggle button in PhoneGAP ? I want a button that changes color if clicked and when clicked again it must go back to default color . Any idea how to do it in ? I've edited my post my it can be easy fro you guys to help me out ,because now i'm really confused on how to do this,the simple stuff but trick. ``` `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); }` ```

Original source