how to get data from url with jquery

前端 未结 4 1169
礼貌的吻别
礼貌的吻别 2021-01-13 01:13

Is it possible to get data from an url with jquery

for example if you have www.test.com/index.html?id=1&name=boo

how to get id and name?

4条回答
  •  臣服心动
    2021-01-13 02:03

    Here i have done complete solution for above issue. please check demo link as shown below:

    For that, you have first include latest jquery.js and querystring-0.9.0.js scripting files in header tag.

    Demo: http://codebins.com/bin/4ldqpac

    HTML

    
      abc
    
    

    JQuery

    $(function() {
        $("a").click(function() {
            setTimeout(function() {
                var param1 = $.QueryString("param1");
                var param2 = $.QueryString("param2");
                alert(param1);
                alert(param2);
            }, 300);
    
        });
    });
    

    Demo: http://codebins.com/bin/4ldqpac

提交回复
热议问题