如何修改html中a标签鼠标悬停上去浏览器左下角显示的路径,左下角显示的是假路劲,点击后跳转到真实路径
3条回答 默认 最新
简效 2023-03-15 14:34关注可以通过js点击事件来处理,如
html<a href="www.baidu.com" data-href="www.12.com">baidu </a> <a href="www.baidu.com" >baidu </a>js
const allA = document.querySelectorAll('a'); allA.forEach((item)=>{ item.onclick = function(e){ if(this.getAttribute("data-href")){ e.preventDefault() window.location.href = this.getAttribute("data-href"); } } })本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报解决 1无用