111
This commit is contained in:
29
header.html
29
header.html
@@ -34,13 +34,38 @@
|
||||
<div class="home--nav__phone">
|
||||
<!-- <div class="home--nav__phone--text" onclick="toLogin()">登录</div> -->
|
||||
|
||||
<a href="login.html" class="home--nav__phone--text">登录</a>
|
||||
<a href="login.html" class="home--nav__phone--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>
|
||||
|
||||
Reference in New Issue
Block a user