JS 中的新功能,如何检查我的查询字符串之一是否有值?
示例:我有 result.aspx?loc=3。如果我的查询字符串 loc 有值,如何在 javascript 中检查这一点。我需要这样做,因为我将使用 $('#target').css({'display':'none'});到某个div
最佳答案
尝试location.search
The search property returns the query portion of a URL, including the question mark (?).
可以这样调用:
<script type="text/javascript">
document.write(location.search);
</script>
关于javascript - 使用 javascript 检查查询字符串是否有值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3442752/