Reputation: 15950
I have following structure:
<label></label><input type="text" id="t1" /><label class="a">fsafs<label>
Now I want a jquery which can match only those labels with class "a" and it should be after id "t1"
I also want clear content of that label
Please help
Upvotes: 0
Views: 1119
Reputation: 723448
For selecting only one label.a
that comes immediately after #t1
, use +
:
$('#t1 + label.a').text('');
For all sibling label.a
elements that come after #t1
(i.e. on the same level), use ~
:
$('#t1 ~ label.a').text('');
Upvotes: 7
Reputation: 50009
This should work for you
$(document).ready(function(){
$('#t1').nextAll('label.a').html('');
})
Upvotes: 2