如何在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)
使用此代码:
var a = location.href;
var b = a.substring(a.indexOf("?")+1);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9794 次 |
| 最近记录: |