如何在javascript中获得问号后的url值

use*_*529 8 javascript

如何在javascript中的问号后获取网址值?

我想要以下行为:

if value is yes then 10+2 
else if value is no then 10.
Run Code Online (Sandbox Code Playgroud)

我想输出警报消息.

<div class="col-xs-4 col-sm-4 col-md-4 text-center width100">
    <a href="piccal.html" class="btn btn-success" id="yes">PIC Grant Calculator</a>
</div>
<div class="col-xs-4 col-sm-4 col-md-4 text-center width100">
    <a href="piccal.html" class="btn btn-danger" id="no">PIC Grant Calculator</a>
</div>

<script> 
if (value == no) {
    alert('hello');
}
</script>

<script> 
if (value == yes) {
    alert('hi');
}
</script>
Run Code Online (Sandbox Code Playgroud)

And*_*aal 10

使用javsacript并输入:

location.search
Run Code Online (Sandbox Code Playgroud)


kp *_*ngh 8

使用此代码:

var a = location.href; 
var b = a.substring(a.indexOf("?")+1);
Run Code Online (Sandbox Code Playgroud)