亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 js 添加 html 后標簽鏈接不起作用

使用 js 添加 html 后標簽鏈接不起作用

HUX布斯 2024-01-18 14:36:22
伙計們。我需要一些幫助我希望在單擊標簽中的所有范圍時重定向頁面,但是如果單擊 p 標簽不起作用首先我上傳我的代碼html  <div id="news" class="news">     <a href="{{ post.address }}" onmouseover="newsMouseOver(this);" onmouseout="newsMouseOut(this);">        <p class="news-title">{{ post.limit_title }}</p>        <p class="news-date">{{ post.created_at|date:"Y.m.d" }}</p>     </a>  </div>CSS.news {  width: 501px;  height: 50px;  border-radius: 5px;  background-color: #ffffff;  margin-top: 9px;  font-size: 13px;  color: #666666;  position: static;}.news a {  border-radius: 5px;  color: #666666;  display: flex;  height: 50px;  align-items: center;  position: relative;}.news a p {  font-size: 13px;  font-family: "Noto";  color: #666666;  margin-left: 20px;}.news a:hover p {  font-family: "Noto-Medium";  color: #333333;  position: static;}.news a:hover {  border: 1px solid #24b97e;}.news a .news-date {  position: absolute;  top: 18px;  right: 15px;  color: #bbbbbb;}.news a:hover .news-date {  padding: 0;  color: #999999;  position: absolute;  right: 10%;  text-align: end;}.news a span {  background-color: #24b97e;  color: white;  position: absolute;  width: 8%;  top: 0;  right: 0;  height: 100%;  display: flex;  vertical-align: middle;  justify-content: center;  align-items: center;}js// all find p tagvar re_html = /<\s*p[^>]*>([^<]*)<\s*\/\s*p\s*>/g;// inner textvar re = /<\s*p[^>]*>([^<]*)<\s*\/\s*p\s*>/;function newsMouseOver(self) {  let origianl_html= self.innerHTML;  let innerTextList = origianl_html.match(re_html);  let innerText1 = re.exec(innerTextList[0]);  let innerText2 = re.exec(innerTextList[1]);  self.innerHTML = "<p class='news-title'>" + innerText1[1] + "</p>\    <p class='news-date'>" + innerText2[1] + "</p>\    <span><i class='fas fa-angle-right'></i></span>"}這是我的代碼當鼠標懸停在標簽上時,更改 html 代碼并設置樣式并且,當鼠標懸停到標簽時返回代碼和樣式最后,刪除 js 時鏈接正常工作但我需要js代碼我該怎么辦..
查看完整描述

1 回答

?
30秒到達戰場

TA貢獻1828條經驗 獲得超6個贊

嘗試添加pointer-events: none到鏈接的絕對定位子級...聽起來絕對定位使它們懸停在/阻止父級。



查看完整回答
反對 回復 2024-01-18
  • 1 回答
  • 0 關注
  • 161 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號