[英]Issue regarding cloneNode in javascript
I am using javascript cloneNode method to clone a table row which is actually hidden. 我使用javascript cloneNode方法来克隆实际隐藏的表行。 But the row is being cloned with that hidden property.
但是该行正在被隐藏的属性克隆。 I dont want that.
我不想那样。 I want that when that row will be cloned it will have visibility on.
我希望当克隆该行时,它将具有可见性。
That particular table row is: 那个特定的表行是:
<tr style="visibility:hidden;">
<td><input size=25 type="text" id="latbox"/></td>
<td><input size=25 type="text" id="latbox"/></td>
<td><input size=25 type="text" id="latbox"/></td>
<td><input size=25 type="text" id="latbox"/></td>
<td><input size=25 type="text" id="latbox"/></td>
<td><img alt="Icon" src="/assets/add-icon.png" id="addmorePOIbutton" onclick="insRow()" /></td>
<td><img alt="Icon" src="/assets/minus-icon.png" id="delPOIbutton" onclick="deleteRow(this)"/></td>
</tr>
And the javascript code where I am cloning this row is: 我克隆这行的javascript代码是:
var x=document.getElementById('POITable');
var new_row = x.rows[1].cloneNode(true);
x.appendChild( new_row );
So, how to set, rather control the style of the new cloned row? 那么,如何设置,而不是控制新克隆行的样式? Please give some hints.
请给出一些提示。
Please give me javascript solutions only (no jquery). 请给我javascript解决方案(没有jquery)。 I need to develop the project using javascript.
我需要使用javascript开发项目。
First, use 0 instead 1 for the index. 首先,使用0代替1作为索引。
next you can set style visibility to visible before adding the row to the table. 接下来,您可以在将行添加到表之前将样式可见性设置为可见。
var x=document.getElementById('POITable');
var new_row = x.rows[0].cloneNode(true);
new_row.style.visibility = "visible";
x.appendChild( new_row )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.