jquery - preventDefault doesn't work on some links -
i've been writing extension disables links on pages through following code:
$('a[href]').each(function() { $(this).on('click.kill', function(e) { e.preventdefault(); }) })
however, on websites i.e. news.yahoo.com, of links remain active after above script has run (for example, "get new yahoo! mail apps" link @ top). possible reasons cause occur? (90+% of links disabled after above code runs)
edit:
as far know, links exist before script runs.
are links being added after script runs? if so, may need this:
$("body").on( "click.kill", "a[href]", function(e) { e.preventdefault(); } );
Comments
Post a Comment