[英](TS)Property Rows does not exist on type HTMLInputElemet
嗨,我是角度和類型腳本的新手。我需要檢查表是否為空,並根據需要隱藏或顯示div。 我試過了,
var rows = document.getElementById('associatedEmailsTable'))rows;
和
var rows =(<HTMLInputElement>document.getElementById('associatedEmailsTable')).rows;
但兩者都給出了相同的結果,請對此提供幫助。
請建議我如何使用JavaScript查找表tr是否具有任何值。
我的HTML代碼是
<table class="table table-sm table-hover" id="associatedEmailsTable" style="display:none">
<tr>
<th>
Email
</th>
<th>
Action
</th>
</tr>
<tr *ngFor="let oEmailAddress of this.associatedEmailAddresses">
<td>{{oEmailAddress.email}}</td>
</tr>
</table>
問題恰恰是錯誤所說的,“ HTMLInputElemet類型不存在屬性行”。
假設您具有<table id="associatedEmailsTable">...
那么您擁有的就是HTMLTableElement
。 所以:
var rows = (document.getElementById('associatedEmailsTable') as HTMLTableElement).rows;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.