Addind link with existin href.

Posted by Dom on Stack Overflow See other posts from Stack Overflow or by Dom
Published on 2010-04-13T13:31:58Z Indexed on 2010/04/13 13:32 UTC
Read the original article Hit count: 281

Filed under:
|

Hello gurus,

Im trying to create link inside my list tag that will have href inherited from link that already exists in this list tag. Don't know how much sense does it makes, but i have this:

<ul>
    <li><a href="page1.html">Support</a></li>
    <li><a href="page2.html">Products</a></li>
    <li><a href="page3.html">Management</a></li>
    <li><a href="page4.html">Others</a></li>
</ul>

and I need soothing like this:

<ul>
    <li>
        <a href="page1.html">Support</a>
        <div class="slideLink"><a href="page1.html">Click Here</a></div>
    </li>
    <li>
        <a href="page2.html">Products</a>
        <div class="slideLink"><a href="page2.html">Click Here</a></div>
    </li>
    <li>
        <a href="page3.html">Management</a>
        <div class="slideLink"><a href="page3.html">Click Here</a></div>
    </li>
    <li>
        <a href="page4.html">Others</a>
        <div class="slideLink"><a href="page4.html">Click Here</a></div>
    </li>
</ul>

So far I have managed to add div with class and link within it with "click here" text, but i don't have a clue how to grab link href and add it to my new link.

$('ul li a').each(function(){
    $(this).after("<div class='slideLink'><a href=" + Link + ">Read more</div>");
  });

Thank you for your help in advance.

Best Regards

Dom

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about list