Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery , selector, find, text

I have one very interesting question (for me :) )..

I'm using jquery and I want to find in HTML the first tag after my reference one .

For example my HTML :

    <a href="#" class="A" >A</a>
    <table>
        .....
    </table>
<a href="#" class="B" >A</a>
    <table>
        .....
    </table>
<a href="#" class="c" >A</a>
    <table>
        .....
    </table>

I want to select the first table after <a href="#" class="A" >A</a>, the first table after <a href="#" class="B" >B</a> ... with jquery . Because just this link is reference tag for me in HTML , all tables are the same (don't have any class, ID ...) , and I don't know how many table can be :( ..

Thanks !!!

like image 606
AlexC Avatar asked May 17 '26 09:05

AlexC


1 Answers

Use next:

$('a').click( function() {
    var tbl = $(this).next('table'); // find the next table element following the clicked link
});
like image 144
tvanfosson Avatar answered May 19 '26 22:05

tvanfosson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!