My menu is constructed by consuming web-service returned javascript which looks like below:
strGlobalNav='<ul><li><a href="//testonline/" alt="test Online Main Page">testOnline</a></li><li><a href="//testonline/ec/" alt="Employee Center Site">Employee Center</a><ul><li><a href="//testonline/ec" alt="Employee Center Site">Employee Center</a></li><li><a href="//testonline/ec/awards" alt="Awards & Recognition Site">Awards & Recognition</a></li><li><a href="//testonline/hr/benefits" alt="Benefits Site">Benefits</a></li><li><a href="//testonline/hr/EERelations/Pages/Default.aspx" alt="Employee Relations">Employee Relations</a></li><li><a href="//testonline/hr/Employment/Pages/Default.aspx" alt="Employment">Employment</a></li><li><a href="//testonline/ec/training" alt="test University Site">test University</a></li><li><a href="//testonline/ec/healthandsafety" alt="Health & Safety Site">Health & Safety</a></li><li><a href="//testonline/sites/offices" alt="Office Locations Site">Office Locations</a></li><li><a href="//testonline/ec/travel" alt="Travel Site">Travel</a></li><li><a href="//testonline/ec/tso" alt="Total Service Organization">TSO</a></li><li><a href="//testonline/ec/vidconf" alt="Video Conferencing Services">Video Conferencing</a></li></ul></li></ul>'; document.getElementById('test-nav-wrapper').innerHTML = strGlobalNav;
I need to add class to submenu items for the parent list item that has an <ul><li>
inside of it.
Here is my navigation.
<div class="globalNav">
<div id="test-nav-wrapper"></div>
</div>
Here is the actual fiddle: http://jsbin.com/urIlAlO/1/edit
Why is my script not able to add the class to the menu items. I am trying to convert the dropdown menu to two columned mega menu style stuff.
Please help me understand why the adding class to the dynamic content doesnt work however, if i add html directly it works? Example here: http://jsbin.com/iHaqihI/1/edit