1

我正在尝试使用原型插入将元素添加到现有的 html 内容中。下面是我正在处理的 html

<table id="productGrid_table" class="data" cellspacing="0">
<thead>
    <tr class="filter">
        <th>
            <div class="range">
            </div>
        </th>
    </tr>
</thead>

在这里,我想在 <tr class="filter"> 中添加另一个 <th>,我正在尝试使用下面的原型代码来实现这一点

$('filter').insert("<th><div class='field-100'></div></th>");

请提供一些建议我在这里做错了什么???

4

1 回答 1

1

在 PrototypeJS $('filter')中选择id="filter"的元素。如果要按类选择,请使用 $$ 函数。像这样的东西:

$$('.filter')[0].insert("<th><div class='field-100'></div></th>");

但我建议要么将类名更改为更独特的名称,要么使用 id 而不是类。

于 2013-06-20T09:35:12.933 回答