[英](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.