1

I have a jqm listview. When a user clicks one of the li in the listview I want to animate the li so that it's background color slowly changes to red.

I can't seem to make this work, although I can use .addClass(".red") to instantly turn the li's background-color to red. This approach could work, but I'd want to establish a slower duration for the addClass(), and that doesn't work either.

Check out this fiddle for both approaches

chuck w
  • 1,741
  • 2
  • 15
  • 34
  • Maybe some of these answers can help http://stackoverflow.com/questions/190560/jquery-animate-backgroundcolor – user1234 Oct 07 '13 at 02:24
  • @Tim, Thanks for pointing me to those answers, which I missed on my initial search. Many of the answers are old (2-5 years), and point to the jQuery color animation plugin. It is my understanding that jQuery UI includes support for color animation for several years now, and the plugin is no longer being supported. Regardless, jQuery's `.animate()` should work, but for some reason color animation doesn't seem to work inside of a jqm listview, as shown in the fiddle. – chuck w Oct 07 '13 at 17:23
  • This might sound trivial, but have you considered using CSS transitions on the `
  • ` element? Might not be the answer you are looking for, but might be useful.
  • – Terry Oct 07 '13 at 17:53