Prototypejs 使用id和prototype insert分别使用特定位置和类向现有html添加元素

Prototypejs 使用id和prototype insert分别使用特定位置和类向现有html添加元素,prototypejs,prototype,Prototypejs,Prototype,我试图使用prototype insert将元素添加到现有html内容中。下面是我正在使用的html <table id="productGrid_table" class="data" cellspacing="0"> <thead> <tr class="filter"> <th> <div class="range"> </div>

我试图使用prototype insert将元素添加到现有html内容中。下面是我正在使用的html

<table id="productGrid_table" class="data" cellspacing="0">
<thead>
    <tr class="filter">
        <th>
            <div class="range">
            </div>
        </th>
    </tr>
</thead>
在这里,我想在中添加另一个,我试图使用下面的原型代码来实现这一点

$('filter').insert("<th><div class='field-100'></div></th>");
请提供一些建议,我在这里做错了什么?

在PrototypeJS中,$'filter'选择id=filter的元素。如果要按类选择,请使用$$函数。大概是这样的:

$$('.filter')[0].insert("<th><div class='field-100'></div></th>");
但我建议将类名更改为更独特的名称,或者使用id而不是类。

在PrototypeJS中,$'filter'选择id=filter的元素。如果要按类选择,请使用$$函数。大概是这样的:

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

但是我建议将类名更改为更唯一的名称,或者使用id而不是类。

在本例中,您可以通过使用表中的id以及$$'productGrid\u table.filter'[0]使其更唯一,在本例中,您可以通过使用表中的id以及$$'productGrid\u table.filter'[0]