I am currently updating the background-position property of a div to gradually change its color from left to right. After completing the position transition, I am looking to trigger another action in JQuery to modify the fill of the #event_2 element:
<div class='event' id='event_1'></div>
<div class='connector' id='connector_1'></div>
<div class='event' id='event_2'></div>
$('#event_2').click(function(){
$('#connector_1').css('background-position', '80px 0px');
myPos = $('#connector_1').css("background-position").split(" ");
if(myPos[0] == '100%'){
$(this).css({'background': '#7b9d6f', 'border-color': '#7b9d6f'});
}
});
When the event is triggered, myPos returns [0%, 100%], so how can I detect when myPos[0] reaches 100%?
Please view the Fiddle at https://jsfiddle.net/sL156k3t/