Loading the external javascript, then removing the href attribute from the results

advertisements

I'm trying to load a widget in javascript which creates a HTML table once it has been loaded. Example:

<td class="foo"><a class="bar" href="http://example.com">Example</a></td>

Inside the table are links where I'd like to remove the href attribute. So the result looks like this

<td class="foo"><a class="bar">Example</a></td>

I tried the following jQuery:

function myfunction() {
        $("td a").each(function(){
            if($(this).hasClass("bar")){
                $(this).removeAttr("href");
            }
        });
    };

Reference: http://www.tutorialrepublic.com/faq/how-to-remove-clickable-behavior-from-a-disabled-link-using-jquery.php

I tried it also with onload="myFunction()" but that neither worked out.

Why this is not working? Any input is much appreciated!


have you try:

$(window).load(function(){
    myFunction();
})