0
I’m having trouble creating a code that is simple, I need to click on a div
she changes color and when clicking a second time she opens a alert
stating the name of the color.
Can be in jQuery or js
$(document).click(function() {
$(".cor").css("background", "blue");
});
$(".cor").click(function() {
alert("HTML: " + $("#test").html());
});
Can you explain the logic of colors better? where the color comes from? each div will have a different color?
– Sergio
I don’t know how to do it in Javascript, but my tip would be to create the color patterns in CSS, when you want to change the color, change the CSS class defined in DIV; already to present a
alert
, declare a variable that serves as a counter and click, increment this variable and check for its value, whether or not to display Alert... Here you do not indicate the language you are using, it would help in case you post an example!!!!– Arnaldo Oliveira