5
I have a Button created only in HTML and CSS, and I need that if someone click on it, a block <div>
alter your background-color
. With that maybe:
$(document).ready(function(){
$('#button_on-off').click(function(){
$(".bloco").css('background-color', 'rgba(255, 0, 0, 0.5)');
});
});
But I want when the button is ON it to be transparent and when the button is OFF it will be colored.
Using Jquery.
Well, I’ve already left everything commented and prepared in jsfiddle for you to help me.
Do not call for HTML or CSS code, I believe you will not need, it is necessary to work only in js.
Just open in a new Guide : http://jsfiddle.net/c49fjwmz/.
Thank you very much! It worked! I have one doubt left, if I want, for example that whenever the button is ON there is a variable "connected = true" and when it is OFF there is "connected = false", for other purposes, you could complement for me please ?
– Danillo Eder
jquery toggleClass would also solve this issue well
– Otto