gpt4 book ai didi

javascript - 在 javascript 中创建一个对象,指向带有 "id"的表行

转载 作者:行者123 更新时间:2023-11-28 10:33:08 26 4
gpt4 key购买 nike

我在网上查找有关在 javascript 中创建对象并将其指向 html 中的 id 的信息时遇到困难。

这是迄今为止我所掌握的 JavaScript 内容:

 function countRecords()
{
headRow=new Object();
//point to specific id here?
var rowCount = 0;

HTML:

<table id="prodTable">
<tr><th colspan="8">Digital Cameras</th></tr>
<tr id="titleRow">
<th>Model</th>
<th>Manufacturer</th>
<th>Resolution</th>
<th>Zoom</th>
<th>Media</th>
<th>Video</th>
<th>Microphone</th>
</tr>

最佳答案

当书中说“创建一个对象”时,它的真正含义是“声明一个变量 headRow”,然后获取对 id 为“titleRow”的文档对象的引用。

所以,

var headRow; // create the "object" 
headRow = document.GetElementById('titleRow'); // point to the table row "titleRow"

关于javascript - 在 javascript 中创建一个对象,指向带有 "id"的表行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2457786/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com