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 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    41
    Thanks
    14
    Thanked 0 Times in 0 Posts

    disable underline for certain URL/html code?

    Assume I have the following html code:

    <p>
    <span>URL:</span>
    <a ..... data-pagetype="DEF_ART" href="....">http://www.foobar.com/aaa/bbb<a>
    </p>

    The link appears on the webpage with underlining. I want to have it no underlined and to apply the no-underline attribute by javascript.

    The following Javascript code does NOT work:

    document.querySelector('a[data-pagetype="DEF_ART"]').setAttribute('style','text-decoration:none');

    or (with jQuery lib):

    $("p:contains('URL:')").css("style", "text-decoration:none");

    How else can I apply no-underline instruction to the HTML code?

    Peter

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,604
    Thanks
    24
    Thanked 647 Times in 646 Posts
    Not JS, CSS
    Code:
    <style type="text/css">
    a{
        text-decoration: none;
    }
    </style>
    Of course this removes the underline from all anchors.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #3
    New Coder
    Join Date
    Dec 2011
    Posts
    41
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Thank you. But I don't want to do this in the original CSS stylesheet but AFTERWARDS from Javascript.

    So agaiN:

    How would a javascript cmd look like which modifies the attribute ON TOP of an existing CSS?

  • #4
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,604
    Thanks
    24
    Thanked 647 Times in 646 Posts
    javascript:
    Code:
    $( "a[href]").css("text-decoration", "none");
    This works on all anchors
    Code:
    $( "a[data-pagetype='DEF_ART']" ).css("text-decoration", "none");
    More specific.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • Users who have thanked sunfighter for this post:

    pstein (02-27-2014)


  •  

    Posting Permissions

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