×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Matthew Speicher
Added: Jun 24, 2016 2:21 PM
Views: 9
Tags: no tags
  1. jQuery(document).ready(function () {
  2.     var $downsell = jQuery('div.element p').children('a'),
  3.         $durl = $downsell.attr('href');//retrieve href from <div class="element"><p><a href="some-link"></a></p></div>
  4.     var $address = window.location.href;//get url in window browser
  5.     var $param = $address.replace('http://www.somedomain.com', '');//throw away the domain host
  6.     if ($param != '') {
  7.         $downsell.attr('href', $durl + $param);//combine the old link with the new one
  8.     }
  9.     console.log($param);//check the result using web developer console
  10. });