Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript This one is a doozy, lets see if you can solve it. [SOLVED]

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #28024
    noahgelman
    Participant

    The goal is to take an unordered list of websites, like the following:

    Code:
    • website.com
    • website2.com
    • website3.com
    • website4.com

    And wrap them in a link.

    Too easy? ha ha, not done!

    I also want it to add a href="http://" with that link.

    Still too easy? Let’s add one more thing.

    I want to copy the text of the link (i.e website.com or website2.com etc.) and insert it in that href="http://" to make a complete functioning link that links externally for all of the sites in the list.

    Can you solve it?

    #70963
    Makeshift
    Member

    See how this works:

    Code:
    $(“ul#site-list li”).wrapInner(““);
    $(“ul#site-list li a”).each(function(){
    $(this).attr({
    href: “http://” +$(this).html(),
    target: “_blank”
    });
    });
    #70964
    noahgelman
    Participant

    Fantastic!
    Very well done :)

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.