Attaching hashtag to URL with javascript

后端 未结 5 1673
暗喜
暗喜 2020-12-07 20:47

I want to build an ajax site without sacrificing SEO. My question is: If I have link on my page like this:

   

        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-07 21:39

    Although simplicity is best, but if you just want to automate this process or make it genericise then you can use this lite plugin jquery.hashTag.js

    $('a').hashTag({
        source: function() {
          return $(this).attr('id');
        }
      });
    

    Just put this snippet inside $(document).ready.

    It will do rest of the work itself. Like auto clicking on the link whose id was provided as the hash.

提交回复
热议问题