I have some jQuery navigation, and I’d like to add the parent anchor to the child ul in the dropdown so that this:
<li class="parentUl">
<a class="parentLink" href="somewhere">Parent Link</a>
<ul class="childUl">
<li class="childUl">
<a class="childLink">Child Link</a>
</li>
</ul>
</li>
becomes this:
<li class="parentUl">
<a class="parentLink" href="somewhere">Parent Link</a>
<ul class="childUl">
**<li class="parentUlClone">
<a class="parentLinkClone" href="somewhere">Parent Link</a>
</li>**
<li class="childUl">
<a class="childLink">Child Link</a>
</li>
</ul>
</li>
Any thoughts
Here is a solution for your case that should get you started. It should work with multiple “parentUl” as well.
Here is the code:
The original HTML:
The resulting HTML:
Note that I pulled out the
atag instead of cloning the entirelielement. You may want to do that differently.Here is a fiddle to play around with it: http://jsfiddle.net/xonev/U6djs/