全部代码如下
<style> .foot{ width: 100%;margin:0 auto; height: 80px; background: #5283ff;} #footnav{ list-style: none;display: flex;justify-content: center;} #footnav li{ font-size: 18px; padding-top:25px;} #footnav li a{ color: #fff6f2; text-decoration: none} </style> <div class="foot"> <ul id="footnav"> <li><a href="">首页|</a></li> <li><a href="">关于我们|</a></li> <li><a href="">产品展示|</a></li> <li><a href="">新闻中心|</a></li> <li><a href="">联系我们|</a></li> </ul> </div> <script> var a=document.getElementById("footnav"); var b=a.firstElementChild.firstChild; console.log(b); console.log(typeof(b)); var c = "首页"; console.log(typeof (c)); console.log(c); var lastelement = a.lastElementChild; var abq=lastelement.children; var lastelementintexe=lastelement.innerText; var replaceok =lastelementintexe.replace("|",""); abq[0].innerText=replaceok; </script>