![]() |
.AddClass after element is dynamically written by script
I'm having some difficulty calling an .addClass() on a dynamically created list of items which is populated after the DOM loads.
The initial HTML starts off as: Code:
<div id="productSlider">Since the OL is added after the DOM has finished downloading I can't do a standard .addClass() on the OL's list-items since they don't exist yet. The HTML turns into this: Code:
<div id="productSlider">But I can't quite figure out why it's not working. Here's the jQuery snippet I made: Code:
jQuery(function() {Any help would be AMAZING because this is really frustrating. Thanks guys! :thumbsup: |
Please tell us about your actual intention because there is definitely some better way to do what you want. Why do you need to add a class “hasItems”? Also, you need to check for the length of the list items (children) of the ol, not the ol itself.
And your fiddle seems to work, by the way, you just need to choose the right framework. |
Ah, frameworks are hard :p
Quote:
|
RESOLVED
big thanks to VIPStephan for pointing out I have to call the .length() on the li, not the ol. Got it working now! Thanks man. Code:
jQuery(function() { |
| All times are GMT +1. The time now is 07:29 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.