jQuery rewrite href

Posted by user317188 on Stack Overflow See other posts from Stack Overflow or by user317188
Published on 2010-04-15T06:25:07Z Indexed on 2010/04/15 6:43 UTC
Read the original article Hit count: 307

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX