How to use jquery to manipulate the querystring

后端 未结 6 2028
别跟我提以往
别跟我提以往 2021-02-08 22:36

I have a select dropdown with id\'s mapped to values. On the onChange event I want to redirect to the same url but with \'id=value\' appended to the querystring.

How do

6条回答
  •  悲&欢浪女
    2021-02-08 23:24

    setting window.location.search will update the url's query string (and overwrite a value if it already exits)

    $('#selector').change(function(){  
      window.location.search = "id=" + $(this).val();
    }); 
    

提交回复
热议问题