嗨,我是angular和type脚本的新手。我需要检查表是否为空,并根据需要隐藏或显示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>
答案 0 :(得分:2)
问题恰恰是错误所说的,“ HTMLInputElemet类型不存在属性行”。
假设您拥有page.evaluate
,那么您拥有的是page.$eval
。
所以:
const puppeteer = require ('puppeteer');
(async () => {
const browser = await puppeteer.launch({ headless : false });
const page = await browser.newPage();
await page.goto('https://www.handelsregister.de/rp_web/mask.do?Typ=e');
await Promise.all([
page.click('input#landNW'), // set a filter
page.click('input[type=submit]'), // submit the form
page.waitForNavigation(), // wait for the page to load
]).catch(e => console.log(e));
// Print the number of allowed results (must be 200)
console.log(await page.$eval('#inhalt p', el => el.textContent.match(/\d+ hits/)[0]));
await Promise.all([
// Manual clicking of the link
page.$eval('p a', el => el.click()),
page.waitForNavigation()
]).catch(e => console.log(e));
// Print the number of allowed results (must be 400 now)
console.log(await page.$eval('#inhalt p', el => el.textContent.match(/\d+ hits/)[0]));
await browser.close();
})();