나는 어려움을 겪을 수행하 찾을 수 있고 교체의 특성값입니다.
고려 html:
<tr id="rules[0]">
<td>
<input id="rules0.isActive1" name="rules[0].isActive" type="checkbox" value="true"/><input type="hidden" name="_rules[0].isActive" value="on"/>
</td>
<td>
<select id="rules0.leftCondition.name" name="rules[0].leftCondition.name">
...
</select>
</td>
내가 찾는 것을 업데이트 각
내가 사용하는 이 JQuery snippet:
$(newRow).find('[id*="rules"]').each(function(){
// Update the 'rules[0]' part of the name attribute to contain the latest count
this.name.replace('rules\[0\]','rules\[$count\]');
});
는 newRow 변수를 잡고 전
나는 어디에서 잘못된 것까요?
감사
를 업데이트 특성의 요소에 사용해야 합니다.attr 기능입니다. 또한,사용하는 경우 이에 jQuery 컨텍스트를 사용해야 합$(this)문입니다. 내가 이해하는 경우 당신의 의도를 해야하므로 무언가가 다음과 같다:
$(newRow).find('[id*="rules"]').each(function(){
// Update the 'rules[0]' part of the name attribute to contain the latest count
$(this).attr('name',$(this).attr('name').replace('rules\[0\]','rules\[$count\]'));
});