yaip
Posts: 0
Joined: Sun Dec 09, 2012 2:07 am

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?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How to change the color property of a button

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/

yaip
Posts: 0
Joined: Sun Dec 09, 2012 2:07 am

How to change the color property of a button

Thx. I looked at the example. Still not clear how to change the color.

yaip
Posts: 0
Joined: Sun Dec 09, 2012 2:07 am

How to change the color property of a button

I have:

Tiggzi('btn').style.bgcolor="#ffffff";

This doesn't work.

yaip
Posts: 0
Joined: Sun Dec 09, 2012 2:07 am

How to change the color property of a button

** Solved **

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How to change the color property of a button

Great. Can you post the code for other users?

yaip
Posts: 0
Joined: Sun Dec 09, 2012 2:07 am

How to change the color property of a button

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

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How to change the color property of a button

What browser? Same result in a different browser? Try the click event but with something as alert(...).

yaip
Posts: 0
Joined: Sun Dec 09, 2012 2:07 am

How to change the color property of a button

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.

yaip
Posts: 0
Joined: Sun Dec 09, 2012 2:07 am

How to change the color property of a button

try it yourself

Return to “Issues”