Reputation: 8138
I have the following html structure that gets repeated as rows in a table
<div class='class1'> <input type="checkbox" id="some_id" checked> </div>
<div class='class2'> <label> Some Label </label> </div>
<div class='class3'> Some Text </div>
When a checkbox is selected, I get the text assoicated with it using the jquery selector
this.$('#some_id').parent().next().next();
Is there a better way of achieving this ?
Upvotes: 0
Views: 90
Reputation: 1249
$(this).parent().siblings('.class3').text();
or
$('#some_id').parent().siblings('.class3').text();
or try this:
$('#some_id').parent().nextAll().eq(1).text();
Upvotes: 2