Add to href attribute of existing link


/ Published in: jQuery
Save to your folder(s)

Redirect Links to Internal Page with Orignal Link as #hash


Copy this code and paste it in your HTML
  1. jQuery("div#listings-widget a").each(function() {
  2. var path = jQuery(this).attr('href');
  3. var newpath = "http://localhost/WandP/listings/#" + path;
  4. jQuery(this).attr('href', newpath);
  5. });
  6.  
  7.  
  8. //Find #hash in current url and load in iframe
  9. var url = window.location;
  10. var anchor = url.hash;
  11. var newanchor = url.hash.substring(1);
  12.  
  13. jQuery(document).ready(function() {
  14. jQuery("iframe").attr("src", newanchor);
  15. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.