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

2023-03-29  本文已影响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>
上一篇 下一篇

猜你喜欢

热点阅读