How to implement such switching classes?

such a situation, there are 4 blocks, 2 buttons.. each button for 2 units.
By default, one button class "active" and block 2 active (displayed).
Need, something hovering - changing class clicking remained and changed blocks (if you pressed the wrong button that is already active).
Ie page loaded = pressed the first button (there is class), removed the first 2 blocks. Lead the mouse class the change. Clicked on another button = pressed now she (her class) and implemented 2 other block.
Even hovering can not think of how to implement, I thought about, but no)
UPD: well, pressing with the default.. implemented Guidance is not given)
March 23rd 20 at 19:32
1 answer
March 23rd 20 at 19:34
If I understand correctly, then approximately so. Could do without the duplication of classes, but then the old classes need to remember. For example, to write to a variable in js or data-attribute.
Yes, the result is what you want.. Just like heaps of classes to get rid of, it is not clear, you get a jumble of JS, apparently - arne commented on March 23rd 20 at 19:37
I understand if the data-attribute to do, it will be the same, only less classes instead of the base class attribute in js working with antibottom is where the base class now.
but if in the js variable, it is an object with css properties and instead of adding/removing classes to change the objects? it's kind of interesting - arne commented on March 23rd 20 at 19:40
Well, Yes, exactly. But don't be afraid to write code. More or less decent sites with thousands of lines of CSS and hundreds of lines of JS. And it is at least. - Talon.V commented on March 23rd 20 at 19:43
no, it's all in the JS classes necessary to describe, I tried a lot.. either there, or there, not leaving) thank you. - arne commented on March 23rd 20 at 19:46
@arne, About the data-attribute, all the way, but that's about js something not understood. It may, of course, something I do not know, but such objects are not heard. CSS in js, you can edit directly or to work with classes like all. I was just referring to the record of the names of classes for each block in the array to when moving the cursor to retrieve and replace the classes back. - Talon.V commented on March 23rd 20 at 19:49
@Talon.V, and so only more work, now directly enter the class, and there's still the blocks with the names) I thought all css properties to move the variable in js as an object, this object takes the jQuery function css({ }). I tried, but realized it was necessary then all of the css is clean and in js to transfer) the same to the same) because removeClass is, but removeCssObject some not :D that block targetwe classes basic) In General, will.. Array list of classes is required, not so much on the styles button is) - arne commented on March 23rd 20 at 19:52

Find more questions by tags jQuery