how to change variable value in links with jquery
<p>I want to change the variable values in all links on the page.
If the links looks like this:</p>

<pre><code>&lt;a href="http://www.mypage.com?type=iPhone&amp;userId=1"&gt;The 1 link&lt;/a&gt;
&lt;a href="http://www.mypage2.com?type=iPhone&amp;userId=1"&gt;The 2 link&lt;/a&gt;
</code></pre>

<p>I want to change <code>type=iPhone</code> to <code>type=Android</code>. But I don't know how to find the <code>type=iPhone</code> so I can replace it?</p>

<p>What is the best way of doing this?
Thanks.</p>

<p>Ok, this is my real code.</p>

<p>What Im trying to do is to check for the user agent and change the appType=iPhone if it is an android.</p>

<pre><code>    var ua = navigator.userAgent;
    if (ua.indexOf("Android") &gt;= 0) {
        var androidversion = parseFloat(ua.slice(ua.indexOf("Android") + 8));
        if (androidversion &lt; 4.0) {
           alert("You have an old Android");

        }
        var apptype='appType=Android';
        alert(apptype);

        $("a[href*='appType=iPhone']").attr("href", function () {
        return this.href.replace("appType=iPhone", "appType=Android");
        });
    }
    else
    {   
        var apptype='appType=iPhone';
        alert(apptype); 


    }
</code></pre>

<p>And with this it is not changing the appType=iPhone at all, I dont know what Im missing?</p>
