Get the parameter string in javascript using jquery
<p>I have these links :</p>

<p>Block 1 : </p>

<pre><code>&lt;a href="/Products?dep=56&amp;cat=252&amp;tab=2"&gt;Adapters&lt;/a&gt;
&lt;a href="/Products?dep=58&amp;cat=654&amp;tab=2"&gt;Battery&lt;/a&gt;
</code></pre>

<p>After click on the link in Block1 , then I start to click on Block2: </p>

<p>Block 2 : </p>

<pre><code>&lt;a href="javascript:SearchClick();"&gt;&lt;img src ="/Content/Images/Top/searchbutton.png"/&gt;&lt;/a&gt;
</code></pre>

<p>I can get the parameter value such as dep=56,cat=654 by using these jquery.</p>

<pre><code>function getParameterByName(name) {
   name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
   var regexS = "[\\?&amp;]" + name + "=([^&amp;#]*)";
   var regex = new RegExp(regexS);
   var results = regex.exec(window.location.href);
    if (results == null){
         return "";
    }else{
         return decodeURIComponent(results[1].replace(/\+/g, " "));
    }

   function SearchClick() {

        var cur_url = window.location.href;
        var depId       = getParameterByName("dep");
        var catId       = getParameterByName("cat");
        var searchStr   = getParameterByName("search");
        var url_add = "";

        if (depId != "") {
            url_add += "&amp;dep=" + depId;
        }

        window.location = "/Products?tab=2"+ url_add;

    }
</code></pre>

<p>But now I exchanged the link in Block 1 with </p>

<pre><code>&lt;a href='javascript:void(0);' dep='" + work.ID + "'&gt;" + work.ProName + "&lt;/a&gt; 
//it works well
</code></pre>

<p>So how can I get the value of <code>dep</code> in Block 1 by using javascript or jquery when I click on the the Block 2 link?</p>

<p>Thanks so much for all your answers.</p>
