This commit is contained in:
myTest383
2025-04-30 09:10:15 +08:00
parent 56914bea40
commit 49d281dcc3
5 changed files with 379 additions and 40 deletions

View File

@@ -34,13 +34,38 @@
<div class="home--nav__phone">
<!-- <div class="home&#45;&#45;nav__phone&#45;&#45;text" onclick="toLogin()">登录</div> -->
<a href="login.html" class="home&#45;&#45;nav__phone&#45;&#45;text">登录</a>
<a href="login.html" class="home&#45;&#45;nav__phone&#45;&#45;text" id="login">登录</a>
</div>
</div>
</body>
<script>
if (localStorage.getItem('userName')==null){
var name = localStorage.getItem('userName')
// 获取元素引用
const link = document.getElementById('login');
// 方法1: 使用innerHTML
link.innerHTML = name;
// // 方法2: 使用innerText (更安全防止XSS攻击)
// link.innerText = name;
//
// // 方法3: 使用textContent
// link.textContent = name;
link.href = "serve.html";
}
</script>
<script>
$(document).ready(function() {
$(".home--nav__tab--item >a").each(function() {
if ($($(this))[0].href == String(window.location))
@@ -49,4 +74,4 @@
});
});
</script>
</html>
</html>