Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding image before links in a div

    I'm rusty on my javascript and know enough to get by but I have been trying to firgure this out for days. I want to add linkable images before each link within a div. Basicly a preview button to get the links href to play within the website in a flash audio player. but all I want to know is how to get the images before the links. This is what I have.

    Code:
    for (var i=0; i<document.links.length; i++) {
      document.links[i].target = document.links[i].target.replace("_self","_blank");
      var linkurl = document.links[i].href.value;
      var saveimg = document.createElement('img');
      saveimg.setAttribute('src', 'http://www.babybums.co.uk/Portals/69/orange-star.gif');
    saveimg.setAttribute('style','width:16px!important;height:12px!important;border:none!important;');
      var parent = document.getElementByName('list');
      parent.insertBefore(saveimg); 
    }
    Any help would be great,
    Thanks in advance,
    Joe

  • #2
    Regular Coder
    Join Date
    Mar 2009
    Location
    Portland Oregon
    Posts
    690
    Thanks
    44
    Thanked 63 Times in 62 Posts
    parent.insertBefore(saveimg)

    I think you want

    document.appendChild(saveimg)

  • #3
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    But I want it before the link not after, but regardless that doesn't work either.

    any other ideas?


  •  

    Posting Permissions

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