2012-06-25 59 views
-1

我希望向id conCol添加'1'使其成爲conCol1。請有人可以告訴我如何解決這個問題,因爲我下面的陳述不起作用。另外,是否有可能得到「第一列」的值,即條件#0使其成爲條件#1?使用jquery獲取元素的第n個子值

newElem.children('select :nth-child(2)').attr('id', 'conCol' + newNum).attr('name', 'name' + newNum); 

<tr id="condition1" class="clonedInput"> 
       <td class="first-column">Condition #0</td> 
       <td><span style="float:left; padding-right: 10px;"> 
       <select id="conCol" name="conCol" class="standard_select" style="width:147px; background:#fff;"> 
+0

你試圖讓'select'標籤或者是你想獲得選項? – Cfreak

回答

0

假設newElemtr元(包在jQuery的):

newElem.find('select').attr('id', 'conCol' + newNum).attr('name', 'conCol' + newNum); 
newElem.find('.first-column').text('Condition #1'); 

的文檔.find().text()

相關問題