не работает nextElementSibling в теге <Table>
Добрый день.
Нужно при нажатии курсором в Input, чтобы все три CheckBoxа которые стоят сразу после Input - очищались. Делаю так <table border="1"> <tr> <td> <input name="placeName" class="my-input-place_0" value="placeValue" onfocus="on(this)"> </td> <td class="tdRow emptyCheckbox"> <input id="id_op" name="opVod" type="checkbox" class="rfield empty_field_checkbox" align="center" style="width: 26%;"> <input id="id_op" name="opKy" type="checkbox" class="rfield empty_field_checkbox" align="center" style="width: 26%;"> <input id="id_op" name="opLi" type="checkbox" class="rfield empty_field_checkbox" align="center" style="width: 26%;"> </td> </tr> <tr> <td> <input name="placeName" class="my-input-place_1" value="placeValue" onfocus="on(this)"> </td> <td class="tdRow emptyCheckbox"> <input id="id_op" name="opVod" type="checkbox" class="rfield empty_field_checkbox" align="center" style="width: 26%;"> <input id="id_op" name="opKy" type="checkbox" class="rfield empty_field_checkbox" align="center" style="width: 26%;"> <input id="id_op" name="opLi" type="checkbox" class="rfield empty_field_checkbox" align="center" style="width: 26%;"> </td> </tr> </table>
function on(a) {
var opvo=a.nextElementSibling;
var opki=opvo.nextElementSibling;
var opli=opki.nextElementSibling;
opvo.checked=false;
opki.checked=false;
opli.checked=false;
}
Проблема в том что если я возьму и помещу весь блок хтмл в теги <table> </table> - nextElementSibling перестаёт работать. В чём проблема? Заранее спасибо |
salerius,
<table border="1">
<td>
<input name="placeName" class="my-input-place_0" value="placeValue" onfocus="on(this)">
</td>
<td class="tdRow emptyCheckbox">
<input name="opVod" type="checkbox" class="rfield empty_field_checkbox" align="center" style="width: 26%;">
<input name="opKy" type="checkbox" class="rfield empty_field_checkbox" align="center" style="width: 26%;">
<input name="opLi" type="checkbox" class="rfield empty_field_checkbox" align="center" style="width: 26%;">
</td>
</table>
<script>
function on(a) {
var opvo=a.parentElement.nextElementSibling.firstElementChild;
var opki=opvo.nextElementSibling;
var opli=opki.nextElementSibling;
opvo.checked=false;
opki.checked=false;
opli.checked=false;
}
</script>
Цитата:
Сначала подняться на td, перейти к следующему td, найти первого ребенка и т.д. И id одинаковых не должно быть |
Спасибо за ответ - а можан точнее.
А то запутался Спасибо |
| Часовой пояс GMT +3, время: 02:58. |