开发者

match a label with particular class

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


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('');


This should work for you

$(document).ready(function(){
   $('#t1').nextAll('label.a').html('');
})
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜