I have an onclick function that I want to add an anchor to the href value. I do not want to change the URL's, because I need the site to still function for people without javascript / for SEO purposes. so here is what I have tried using (amoung other things):
jQuery('a[rel=ajax]').click(function () { jQuery(this).attr('href', '/#' + jQuery('a')); });
An orginal link looks like this:
http://www.mysite.com/PopularTags/
URL re-write should look like this, so that AJAX will work:
http://www.mysite.com/#PopularTags
I was able to get some URL's to work by setting a links name value to the same as the href, but it did not work for links with sub-sections:
http://www.mysite.com/Artist/BandName/
So not really sure. Thanks for the help.
I'd suggest to use regular expressions, like
$('a[rel=ajax]').click(function(){
$(this).attr('href', function(){
this.href = this.href.replace(/\/$/, "");
return(this.href.replace(/(.*\/)/, "$1#"));
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With