How to use jquery to manipulate the querystring

后端 未结 6 2023
别跟我提以往
别跟我提以往 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:34

    Try using the split function:

    var url = location.href.split('?')[0] + '?;id=' + $(this).val();
    

    split returns a list made up of the string split up by the string (like '?'), with that string removed.

提交回复
热议问题