[jQuery] TR 복제후, href 값 수정 및 추가
첫번째 tr 을 복제하여 id 값 수정후 추가.
a 태그의 href 값을 수정.
$(".add_file_base_row").each(function(idx, val) {
var newItem = null;
var newItem = null;
if(idx==0) {
newItem = $(this).clone();
newItem.attr("id", "addFileNo" + nNum);
newItem.find("td:eq(0)").find("input").attr("id", "addFileInput"+nNum);
newItem.find("td:eq(0)").find("input").val("-_-::"+nNum);
newItem.find("td:eq(0)").find("a").attr("href", "javascript:addFile("+nNum+")");
newItem.find("td:eq(0)").find("span").attr("id", "uploadImgFile"+nNum);
}
if( nNum == idx+2 ) {
$(this).append(newItem);
}
});
-------------------------------------------------------------------------
<tr id="addFileNo1" class="add_file_base_row">
<th class="txt">파일첨부</th>
<td class="con2">
<input type="text" id="addFileInput1" value="" style="width:353px;" class="border_box2">
<a href="javascript:addFile(1)"><img src="/bt_file.gif" alt="첨부" class="btn"></a>
<span id="uploadImgFile1"></span>
</td>
</tr>
댓글