How to change the color property of a button
I have a button. When the user clicks it, I want to change the color, say from blue to green. How?
Catch up wih the Appery.io community on our forum. Here you'll find information on the lastest questions and issues Appery.io developers are discussing.
https://forum.appery.io/
I have a button. When the user clicks it, I want to change the color, say from blue to green. How?
On click run JavaScript. Select the component in the DOM and update its style. You can select the component directly with jQuery or use Tiggzi(id) function: http://docs.tiggzi.com/javascript-api/
Thx. I looked at the example. Still not clear how to change the color.
I have:
Tiggzi('btn').style.bgcolor="#ffffff";
This doesn't work.
** Solved **
Great. Can you post the code for other users?
Tiggzi('btn').live('click', function() {
var dotoggle = $(this).attr("dotoggle");
if ( dotoggle == "1" ) {
$(this).css('background', 'green');
$(this).attr("dotoggle","0");
}
else {
$(this).css('background', 'red');
$(this).attr("dotoggle","1");
}
});
this works but the problem is that I have to double-click instead of single-clicking it for the color to change
What browser? Same result in a different browser? Try the click event but with something as alert(...).
Chrome on a Mac. I also tried it on FF on a Mac as well as Chrome on PC. Same result. Tells me that something's wrong with my code.
try it yourself