Results 1 to 2 of 2

Thread: change a link

  1. #1
    Join Date
    Jul 2008
    Posts
    81
    Thanks
    38
    Thanked 2 Times in 2 Posts

    Default change a link

    Hi,

    I have a simple link:

    PHP Code:
    <a href="#" id="my">text</a
    and I want to change the href value (#) into another with an external js function, how can I do it?

    Thanks!

  2. #2
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Code:
    function changeLink(id,link) {
    document.getElementById(id).href = link;
    }
    
    changeLink('my','changed.html');
    I'm terrible with JavaScript, but I think the above may work, can't test it for you at the moment though, unfortunately.
    Last edited by Schmoopy; 11-16-2009 at 02:55 PM.

  3. The Following User Says Thank You to Schmoopy For This Useful Post:

    lord22 (11-16-2009)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •