I've checked through the forum and cant seem to find a solution to my problem.
I have an array of id's and I'm iterating through them with a for loop adding mouse events for enter and leave. However the events all bind to the final ID, which is probably a for each issue.
I've put it up on a fiddle below, any help would be appreciated - my brain is a bit frazzled today.
http://jsfiddle.net/shanemccster/e48vu/4/
cards = new Array('#box0','#box1','#box2');
function bindCardEvents(){
for (var i=0; i<cards.length; i++){
var targetID = '#'+$(cards[i]).attr('id');
$(targetID)
.mouseenter(function() {
TweenMax.to(targetID,0.3, {opacity:0.5} )
}).mouseleave(function() {
TweenMax.to(targetID,0.3, {opacity:1})
});
}
}
bindCardEvents();
Thanks
.card), or use[id^=box]selectortargetIDalready overriden by next loop iterations...