I need if JS is enabled then this link will be this
<a href="#" class="collops">see sitemap</a>
And is js is disabled then link shou开发者_如何转开发ld be this
<a href="http://stackoverflow.com" class="collops">see sitemap</a>
You do not need to do such things. Just have the onclick function return false, like this:
<a href="http://stackoverflow.com/" onclick="redirect(this.href); return false;">link</a>
Use a function that runs when your page loads to re-write all of your links (or all selected links). That way page renders with proper anchor tags if JS is off, and if it's on they all get replaced to what you need them to be.
Something along the lines of:
$(document).ready(function(){
$(".collops").attr("href", "#");
});
精彩评论