【问题标题】:radio-button onchange hyperlink to current url + querystring单选按钮 onchange 指向当前 url + 查询字符串的超链接
【发布时间】:2013-06-25 13:31:02
【问题描述】:

我是 javascript 和 jquery 的新手。我的网站正在运行 jquery。

它想使用单选按钮更改 css-link

它有以下单选按钮:

<input type="radio" name="css" value="basic" checked>basic
<input type="radio" name="css" value="round" >round
<input type="radio" name="css" value="zoom" >zoom

我需要的是,当用户更改单选按钮时,脚本应该获取当前 url(例如http://mysite.com/about.php)并将所选按钮值添加为查询字符串(例如http://mysite.com/about.php?css=round)并重定向到该链接带有查询字符串。 (如果当前链接有 ?css=basic 则应将其更改为 ?css=round...)

谢谢

【问题讨论】:

    标签: jquery hyperlink radio-button onchange


    【解决方案1】:
     $("input:radio").each(function(){
            $(this).click(function(){
                window.location.href = "http://mysite.com/about.php" + "?css=" + $(this).val();
            });
        });
    

    【讨论】:

      【解决方案2】:

      快速谷歌搜索为您提供答案!

      this 用于将函数绑定到事件

      this 用于重定向

      this是获取当前url

      this 用于获取不带查询字符串的url

      this 有助于弄清楚如何使用 reg exp

      【讨论】:

      • 谢谢,这正是我所需要的,但我正在努力将它们放在一起。 PL。帮我多一点……
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-03
      • 2016-08-12
      相关资源
      最近更新 更多