1
.find() 메서드에 이상한 문제가 있습니다.jquery .find() 메서드에 이상한 문제가 발생했습니다.
<table id="roleTab" style="padding: 5px; position: relative; top: 10px">
<thead>
....
</thead>
<tbody>
<TMPL_LOOP DATA_ROLES>
<tr id="<TMPL_VAR ID>">
<td><select id="role2" name="role2_<TMPL_VAR ID>" title="The role of the employee"><TMPL_VAR ROLE></select></td>
<td><input id="steps" type="text" name="steps_<TMPL_VAR ID>" size="5" title="Total amount of steps per month" value="<TMPL_VAR STEP>"></td>
<td><input id="measurable_steps" type="text" name="measurable_steps_<TMPL_VAR ID>" title="Measurable steps" value="<TMPL_VAR MEASURABLE_STEP>"></td>
<td><input id="steps_ratio" type="text" name="steps_ratio_<TMPL_VAR ID>" title="'Measurable steps'/'Steps'" value="<TMPL_VAR STEPS_RATIO>%" readonly></td>
<td style="text-align: center"><select id="reopen_rate" name="reopen_rate_<TMPL_VAR ID>" title="How many reopenes after closing the SI"><TMPL_VAR REOPEN></select></td>
<td><select id="w4p" name="w4p_<TMPL_VAR ID>"><TMPL_VAR W4P></select></td>
<td><select id="team" name="team2_<TMPL_VAR ID>"><TMPL_VAR TEAM></select></td>
<td><input id="checkbox" type=checkbox></td>
<td><input id="status2" type="hidden" name="status2_<TMPL_VAR ID>" value="<TMPL_VAR STATUS>"></td>
</tr>
</TMPL_LOOP>
</tbody>
</table>
I 다음 스크립트가 있습니다 :
나는 다음과 같은 HTML을
$(function(){
$('#steps').live("focusout", function() {
var steps = $(this).parents().parents().find('#steps').attr("value");
var meas_steps = $(this).parents().parents().find('#measurable_steps').attr("value");
var value = (meas_steps/steps)*100;
value = parseInt(value);
if(steps && meas_steps){
var t = $(this).parents().parents().attr("id");////////////////////
alert(t);////////////////////////////////////////////////////////////
$(this).parents().parents().find('#steps_ratio').attr("value", value+"%");
}
});
});
내가 (루프 다음) 페이지에 두 행이 있습니다. 첫 번째 ID는 '2'이고 두 번째 ID는 '3'입니다.
문제는 두 번째 행 (첫 번째 행도 될 수 있음)의 단계 필드를 변경하고 경고가 '3'이지만 'steps_ratio'필드의 값이 두 행 모두에 대해 변경되었음을 나타냅니다.
'3'이하의 'steps_ratio'에서만 왜 변경되지 않습니까?
감사
고맙습니다. 그것은 작동합니다! – Mike