I have a javascript snippet that displays a widget on my page. There are links that are output using a script that look like this:
<a href="#" onclick="somefunction()">Link</a>
These links force JS to run. It's great. The problem is the href="#"lack of a "return false;"at the end of the attribute onclick.
When I click one of these links, the browser goes to the top of the document. If the widget is located close to the bottom of the document, this is not good.
Unfortunately, I do not control the output of the script.
Using jQuery, I can link to these links using $("#wxheader ul li a"). I tried the following code, but it does not work:
$(document).ready(function(){
$("#wxheader ul li a").each(function(){
var onclick = $(this).attr("onclick") + "; return false;";
$(this).attr("onclick", onclick );
});
});
jQuery, onclick, "return false;", , script .
?