Firstly @Daniel confused as it said you had mentioned my name then I realised you edited the post
@ouch_stop not sure as to what post you saw the solution but you are right. You cannot change the background property using Hype’s API (yet ;)) I know this is something Jonathan is working on.
The logic of what you are doing is sound however as Hype wraps all elements in a container (div) it is actually counting those divs when working out the “nth-child” of anything. So, even though it works for the first 2 (i.e it’s adding the selected class to the container div but as it’s actually changing the background of those container divs it seems to work) it is actually changing the div that contains the “decoration” element. It gives the same effect but not what you were intending on doing
For a visual of this, open your console inspector for your browser and you’ll see what I mean.
Tha being said, why isn’t it doing anything for the “remove” set. Well, it is but as you cannot give the containing element a class name within Hype so, there is nothing to remove therefore it does nothing
How do I solve this? I hear you scream!!!
Well, using jquery use the following (and by the way, this gets rid of the double click :))
this is all you need so you don’t need the click method just use the above code in each of your functions (the code corresponding to your function that is so one line is all you need in each function i.e add class, remove, etc)
so effectively you’re changing the nth-child to 2 (as you have 2 elements in the group) and then finding the element with the class “HYPE_element” all elements that you create in Hype have this class and then adding/removing/toggling the class for that element.