对于抽样案例: DOM是否为每个输入对象创建一个隐式ID?如果是这样,我该如何访问此ID?
TIA,这是您要求的代码:
<html>
<script>
function addRow(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var newcell = row.insertCell(0);
newcell.innerHTML = table.rows[0].cells[0].innerHTML;
}
</script>
<body>
<INPUT type="button" value="+" onclick="addRow('dataTable')" `enter code here` />
<TABLE id="dataTable" border="1">
<TR>
<TD>
<INPUT type="text" name="txt[]" />
</TD>
</TR>
</TABLE>
</body>
</html>
答案 0 :(得分:0)
不,id是由你和你自己分配的。
您可以使用类似JQuery的内容来隐式查找元素。
$("input").each(function(){});
答案 1 :(得分:0)
Id的这种更具体的用法
http://api.jquery.com/id-selector/
还要为您的Jquery元素添加类
http://api.jquery.com/class-selector/