A
A
Alexander2015-09-27 00:00:58
JavaScript
Alexander, 2015-09-27 00:00:58

How to find the element that lies the element?

<table border="1px" data-table="0">
                    <tbody>
                    <tr>
                        <td><span class="h3">Понедельник </span></td>
                        <td><span class="h3">Вторник </span></td>
                        <td><span class="h3">Среда </span></td>
                        <td><span class="h3">Четверг </span></td>
                        <td><span class="h3">Пятница </span></td>
                        <td><span class="h3">Суббота </span></td>
                        <td><span class="h3">Воскресенье</span></td>
                    </tr>
                    <tr>
                        <td>
                            <ul>
                                <div class="text-center add_task" onclick="ClickAdd(0)"><span>Add</span></div>
                                <li onclick="liClick('0')" data-task="0" class="gg_wp">
                                    Yii Lesson - 1
                                    <input type="checkbox" onchange="checkChange()">
                                    <span class="plus">+</span>
                                </li>
                            </ul>
                        </td>
                    </tr>
                    </tbody>
                </table>

When you click on the Add div, you need to find the table tag and its data-table attribute. Give me some ideas how to do it?
Tried to do so alert(add.prev("table").attr());

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DevMan, 2015-09-27
@kentuck1213

jsfiddle.net/x4hpj6oj

P
prishelec, 2015-09-27
@prishelec

your_element.parentNode.parentNode.parentNode.parentNode.parentNode;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question