<p>The value of time1 is: <span id='time1'></span></p>
<script>
  // Get the value of the expireTime cookie
  var time1 = getCookie('expireTime');

  // Set the value of the time1 span element to the value of time1
  document.getElementById('time1').innerHTML = time1;
</script>
<p>这段代码将在页面上创建一个段落元素,并在其中添加一个空的 span 元素,用于显示 time1 的值。然后,使用 JavaScript 代码获取 cookie 的值,并将其设置为 span 元素的 innerHTML,从而将其显示在页面上。</p>
JavaScript 获取 Cookie 值并输出到 HTML 页面

原文地址: https://www.cveoy.top/t/topic/mwS5 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录