JQuery 찾기:대체의 특성값

나는 어려움을 겪을 수행하 찾을 수 있고 교체의 특성값입니다.

고려 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>

내가 찾는 것을 업데이트 각's name 특성으로 적절한 수를 예를 들어 규칙에[0].isActive 입 업데이트된 규칙에[10].isActive

내가 사용하는 이 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 변수를 잡고 전차단 및 계산을 보유하고 최신 카운터 값입니다. 그러나 때,나는 디버그 이 코드는 것 같"this.이름"가 정의되지 않습니다.

나는 어디에서 잘못된 것까요?

감사

질문에 대한 의견 (1)
해결책

를 업데이트 특성의 요소에 사용해야 합니다.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\]'));
}); 
해설 (0)

이것을 보십시오: 가정 행 특성이 이름이'filterCol'그런 다음 설정할 수 있는 새로운 가치하는 특성

$("#trId").attr("filterCol", newValue);
해설 (0)

당신이 사용해야 한다$(this).attr(&#39;이름&#39;)대신이다.이름이다.

해설 (0)

이것을 보십시오:

$(this).attr('name', $(this).attr('name').replace('rules\[0\]','rules\[$count\]'));
해설 (0)