SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems with colors in a link with document.createElement

    Hi.

    I'm creating a list of links.

    var elnews = document.createElement('a');

    elnews.setAttribute('href', entry.link);
    elnews.setAttribute('target', '_blank');
    elnews.setAttribute('style', 'color:red;');
    elnews.setAttribute('style', 'text-decoration:none;');

    but color doesn't work and text-decoration:none doesn't work, If I eliminate
    elnews.setAttribute('href', entry.link);, then the color works ok.

    Maybe its mixed with the style of the page that holds this thing, but I don't know what happens.

    Any idea???
    Thanks

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,497
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    elnews.style.color='red';
    elnews.style.textDecoration='none';

  3. #3
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks

    works great


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
  •