Hi All,
I have columns of text that start out with the color black, but you have an option to change the color.
I have done my jQuery code to change color when you press a blue, red or black button but the code is quite long.
Does anyone know how I can reduce it?
It is as follows:
The div in my code is this:Code:$(document).ready(function(){ $("#bluesquare1").click(function(){ $("#textblocka").css({"color":"blue"}); }); $("#redsquare1").click(function(){ $("#textblocka").css({"color":"red"}); }); $("#blacksquare1").click(function(){ $("#textblocka").css({"color":"black"}); }); $("#bluesquare2").click(function(){ $("#textblockb, a").css({"color":"blue"}); }); $("#redsquare2").click(function(){ $("#textblockb, a").css({"color":"red"}); }); $("#blacksquare2").click(function(){ $("#textblockb, a").css({"color":"black"}); }); $("#bluesquare3").click(function(){ $("#textblockc").css({"color":"blue"}); }); $("#redsquare3").click(function(){ $("#textblockc").css({"color":"red"}); }); $("#blacksquare3").click(function(){ $("#textblockc").css({"color":"black"}); }); });
Code:<div id = "blacksquare1"></div> <div id = "redsquare1"></div> <div id = "bluesquare1"></div>


Reply With Quote
Bookmarks