score:1
Accepted answer
It's because during the loop action
isn't being reinitialized with an empty object.
Fiddle http://jsfiddle.net/oliverseal/qc75H/1/
It should be:
colors = ['#e03d56', '#fecd6e', '#8fe1bf', '#9ab3f1']
i = 0
txtc = $('.text-cycle').css('color', '#e03d56')
bgc = $('.bg-cycle').css('background-color', '#e03d56')
changeColor = (ob) ->
i++; i = i % 4
$.each ob, ->
action = {}
action[this.toChange] = colors[i]
this.el.animate action,
duration: 8000, complete: () -> changeColor ob
#heights '.max-image-place, .max-image'
changeColor [
{el: txtc, toChange: 'color'}
{el: bgc, toChange: 'backgroundColor'}
]
Related Query
- Jquery toggling each and every div with same id
- Allow objects with same id to be draggable with jQuery
- Get source of each image in div with jQuery
- Adding class to each item after third with jQuery
- How to return a variable with jQuery each function
- Convert array of objects into array by field with Underscore.js or jQuery - JavaScript
- jQUery syntax for multiple groups of checkboxes, each with their own "check all" option
- jquery to loop through each table row and perform math with each row input field
- traverse JSON when object value is an array of objects with jQuery
- jQuery cycle plugin with different timeout values for each slide
- Change color first word of each line with CSS or jQuery
- How to repeat IF statement to each matching element with Jquery
- How to sort an array in JavaScript or jQuery with multiple objects per array record
- Jquery filter out the double class name with each function
- Animating each number on Jquery countdown timer
- How to run a jQuery method for each group of elements
- How to deal with the callback being called multiple times when animating more than one thing in jQuery
- jQuery $.each - Iterate over an array of objects and select a field for each object
- Group objects with same property - javascript
- Run jquery on each table with same classes
- Jquery loop through Json with array of objects and get key name
- jquery each loop call function with parameter
- How to add an increment value for each id attribute within the div contents with cloned jQuery object
- Using JQuery each with Wildcards
- How to iterate in Jquery over json string with multiple objects
- Jquery duplicate making more multiple duplicates with each duplication
- jquery chaining not working in my html with each function
- Using jQuery Attribute Starts With Selector in Each Loop
- Trying to serialize() a group of input fields with jQuery
- changing several objects with jquery
- Create multiple list from array with jQuery Each
- How to hold jquery template files as external template files with multiple templates in each file?
- Problem with jQuery each function iterating over selects
- Moving a large set of HTML objects on the page and rebinding events with jQuery
- jQuery find items with each
- Take each value from same class, make calculations then append it with jQuery
- How to zoom in/zoom out each image in each div with jquery and scale (css)?
- jQuery toggle function not working as expected with each and click function
- How to make elements interact with each other and position with jquery
- jquery .each loop to execute each array item with a delay between them
- Check form to see if any inputs has value with jQuery each method
- appendTo is not working with each in jquery
- Select all children except those in a marked group with jQuery
- jquery Slide Toggle doesn't work with each div
- jQuery - Iterate over Objects with numeric keys
- How to handle empty objects with jQuery .each()?
- Does jQuery create a globally scoped object for each element with an id?
- How to post values for each image with jquery each method?
- jquery function to display arrows that point to buttons with a short explanation for each
- Get length of child elements for each element with jQuery
More Query from same tag
- Character encoding from UTF8 JSON to ISO-8859-1
- Change inner text of icon with Jquery
- jquery datepicker for generated html input not working
- Carousel multiple: How to make arrows target a specific set of slides?
- Detect if user has scrolled to the bottom of a div
- why does this on() trigger right away instead of just binding?
- Transition between html change
- Get source of each image in div with jQuery
- Jquery scroll to target div moves horizontally
- Embedded JavaScript doesn't work?
- How to append a number to an ID inside an XSL file
- slideup once click slidedown div
- OAuth2 (Okta) token generation fails with 401 unauthorized response - client_credentials grant type
- append parameters to URL, avoid duplicates
- Jquery - Fill an input text when select option
- Jqgrid - How to display information in a textbox by row selected on a grid
- How to put the Ajax call array(json) in to a global array?
- Setting up an Whois -script on a delay
- jQuery sorting fails
- Not using CSS classes on each TD to style; using JQuery
- jQuery - Can't clone nested row inside form
- jQuery grep is skipping terms in array
- Sort label with attribute
- How to make jQuery get the .val() of a newly created <input> element?
- How to right click to select text in textarea
- How to apply a jquery plugin to a div which is generated by knockout template
- jQuery .click() activates addClass() & class uses transform: translate to move element
- How to stop multiple jQuery Ajax calls made after multiple times opening different modal windows
- Updating Google Fusion Table Row via $.ajax() POST
- Add class with setTimeout without Jquery