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

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

點擊事件在 IE 中不起作用,但在其他瀏覽器中工作正常

點擊事件在 IE 中不起作用,但在其他瀏覽器中工作正常

ibeautiful 2023-09-18 10:34:48
這是 html 代碼,我在其中添加了指向函數的單擊事件,并且該函數將提醒一些消息。<div class="horizontal-align" *ngFor="let taxId of selectedTaxIds">    <button class="btn btn-rounded" disabled *ngIf="taxId.Tin !== 'All'">         <span >Taxi ID: </span>         <span class="text-semibold pl-4"> {{ taxId.Tin }} </span>         <div class="close-btn" (click)="newfun()" >              <mat-icon class="icon-display"  svgIcon="close"></mat-icon>         </div>     </button></div>newfun(){alert('some message')}這在 chrome 中工作正常,但在 IE 中不行。我嘗試向標簽聲明一個 id,并使用工作正常的 document.getElementById 方法選擇 id。即使在檢查代碼時,我也可以在 IE 開發人員工具事件選項卡中看到單擊事件。請幫我解決這個問題
查看完整描述

1 回答

?
jeck貓

TA貢獻1909條經驗 獲得超7個贊

請檢查HTML5 標準中的按鈕定義

內容模型:表述內容,但不得有交互式內容后代。

根據您的代碼,您想要單擊按鈕元素內的子元素,這在 IE 瀏覽器中不起作用。

我建議您修改代碼如下(將單擊事件添加到按鈕元素,而不是 div 標簽):

<div class="horizontal-align" *ngFor="let taxId of selectedTaxIds">

? ? <button class="btn btn-rounded" disabled *ngIf="taxId.Tin !== 'All'" (click)="newfun()">

? ? ? ? ?<span >Taxi ID: </span>

? ? ? ? ?<span class="text-semibold pl-4"> {{ taxId.Tin }} </span>

? ? ? ? ?<div class="close-btn" >

? ? ? ? ? ? ? <mat-icon class="icon-display"? svgIcon="close"></mat-icon>

? ? ? ? ?</div>

? ? ?</button>

</div>

此外,您還可以將按鈕元素更改為 div 標簽,如下所示:


<div class="horizontal-align" *ngFor="let taxId of selectedTaxIds">

? ? <div class="btn btn-rounded" disabled *ngIf="taxId.Tin !== 'All'">

? ? ? ? ?<span >Taxi ID: </span>

? ? ? ? ?<span class="text-semibold pl-4"> {{ taxId.Tin }} </span>

? ? ? ? ?<div class="close-btn" (click)="newfun()" >

? ? ? ? ? ? ? <mat-icon class="icon-display"? svgIcon="close"></mat-icon>

? ? ? ? ?</div>

? ? ?</div>

</div>


查看完整回答
反對 回復 2023-09-18
  • 1 回答
  • 0 關注
  • 113 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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