开发者

select first div in table and toggle class

this should be simple - I want to use jquery to select the first div with the class="boxgrid captionfull" in the tr class="row-1 row-first" and toggle the class to 'active_labBeitrag'.

<table class="views-view-grid">
 <tbody>
   '<tr class="row-1 row-first">'
       '<td class="col-1">'
         '<span id="thmr_222" class="thmr_call">'
            '<div class="views-field-field-video-standbild-fid">
              '<span class="field-content"><span id="thmr_4" class="thmr_call">'
<div class="boxgrid captionfull" >..........

This doesn't work: $('tr.row-1').children(".boxgrid").toggleClass('active_lab开发者_JAVA技巧Beitrag');


It's because .boxgrid isn't an immediate child, do you need .find() instead of .children() (which only looks at immediate children) here, like this:

$('tr.row-1').find('.boxgrid').toggleClass('active_labBeitrag');
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜