Hi,
First some sample clode:
- <div id="main">
- <h3>Heading 1</h3>
- <div class="detail">
- <table>
- <tr class="dethead" id="item1"></tr>
- </table>
- <table>
- <tr class="dethead" id="item2"></tr>
- </table>
- <table>
- <tr class="dethead" id="item3"></tr>
- </table>
- </div>
- <h3>Heading 2</h3>
- <div class="detail">
- <table>
- <tr class="dethead" id="item4"></tr>
- </table>
- <table>
- <tr class="dethead" id="item5"></tr>
- </table>
- <table>
- <tr class="dethead" id="item6"></tr>
- </table>
- </div>
- </div>
I have a jQuery click event handler on the dethead tr's which is fine.
But what I want to find in this click event handler is the previous <h3> to the clicked <tr>
So if I click on item1, item2 or item3 I want to find the <h3>Heading 1</h3>
I click on item4, item5 or item6 I want to find the <h3>Heading 2</h3>
NOTE: Not all the <h3> will have the same classes, if any class at all.
Been trying various things from
Tree Traversal but have not found the right combination.
Cheers,
Mike