How to get URL parameter using jQuery or plain JavaScript?

前端 未结 30 3208
天涯浪人
天涯浪人 2020-11-21 06:29

I have seen lots of jQuery examples where parameter size and name are unknown.

My URL is only going to ever have 1 string:

http://example.com?sent=ye         


        
30条回答
  •  盖世英雄少女心
    2020-11-21 06:55

    Try this working demo http://jsfiddle.net/xy7cX/

    API:

    • inArray : http://api.jquery.com/jQuery.inArray/

    This should help :)

    code

    var url = "http://myurl.com?sent=yes"
    
    var pieces = url.split("?");
    alert(pieces[1] + " ===== " + $.inArray("sent=yes", pieces));
    

提交回复
热议问题