I have a page with four Divs, all with the class .coloritem:
<div class="coloritemSelected" style="background: Vermelho;" onclick="javascript:showOptionsFor('Vermelho');"> </div>
<div class="coloritem" style="background: red;" onclick="javascript:showOptionsFor('Azul');"> </div>
<div class="coloritem" style="background: red;" onclick="javascript:showOptionsFor('Púrpura');"> </div>
<div class="coloritem" style="background: red;" onclick="javascript:showOptionsFor('Laranja');"> </div>
I would like to know if you have just how to get the div that has such a color, like Red and change it so that it has background: red;
I was testing with this code, but it ends up putting the color in all the Divs:
$(document).ready(function () {
var item = $('.coloritem');
var background = item.attr('style');
if (background == 'background:Vermelho;') {
$(item).css('background', 'red');
};
});
Thanks in advance for any help.