Closed ghost closed 9 years ago
Instead of using classes for all of the colors, it may be a better bet to just change the CSS directly:
// in place of toggleClass
$(this).css('background-color', 'transparent')
// in place of addClass
$('#grid').children().eq(1).css('background-color', 'red')
I've gone back and forth on using that. I think I'm probably asking a peripheral question;
I think the real issue is getting the toggle to work; I think I need to set up a function that removes the particular color class so I'm left with the .white class attributes when I click a card, right?
On Mon, Oct 26, 2015 at 5:10 PM, Robert Thomas notifications@github.com wrote:
Instead of using classes for all of the colors, it may be a better bet to just change the CSS directly:
$('#grid').children().eq(1).css('background-color', 'red')
— Reply to this email directly or view it on GitHub https://github.com/ga-dc/project1/issues/168#issuecomment-151285920.
That sounds like way too much work! I'd really just change the CSS directly.
Also, are you putting commas in your classes? <div class="foo, bar, baz">
is incorrect. It should just be spaces.
Remember that all toggleClass does is look at an element and remove the class if it has it, and add it if it doesn't.
For example:
HTML
<div></div>
JS
$("div").toggleClass("hello");
becomes...
<div class="hello"></div>
HTML
<div class="goodbye"></div>
JS
$("div").toggleClass("hello");
becomes...
<div class="goodbye hello"></div>
HTML
<div class="goodbye hello"></div>
JS
$("div").toggleClass("hello");
becomes...
<div class="goodbye"></div>
just reread this again and see you're suggesting i 86 the toggleClass function altogether for another route. going to try that.
Yawp.
Seems that some colors in css are more equal than others.
Here's my code with a .lime example. The grid is populated with eight colors, and this setup removes .lime from the lime cards, and therefore those cards turn white (attribute in .white). However, when I click on other squares, one of two things happens: 1) some colors now have three classes (.card .INITIALCOLOR, .lime) and the card displays lime. 2) some colors now have three classes (.card .INITIALCOLOR, .lime) and the card displays color in .INITIALCOLOR