美文网首页
js判断 url中是否有标记,参数有就设置div style d

js判断 url中是否有标记,参数有就设置div style d

作者: 吉凶以情迁 | 来源:发表于2023-03-29 14:14 被阅读0次
html
Copy Code
<!DOCTYPE html>
<html>
<body>

<button onclick="checkDebug()">Check Debug</button>

<div id="myDiv" style="display: none;">
  This div will only show if debug parameter is present in URL.
</div>

<script>
function checkDebug() {
  const urlParams = new URLSearchParams(window.location.search);
  const debugParam = urlParams.get('debug');

  if (debugParam !== null && debugParam.toLowerCase() === 'true') {
    document.getElementById("myDiv").style.display = "block";
  }
}
</script>

</body>
</html>

相关文章

网友评论

      本文标题:js判断 url中是否有标记,参数有就设置div style d

      本文链接:https://www.haomeiwen.com/subject/buvmrdtx.html