开发者

select first div in table and toggle class

开发者 https://www.devze.com 2023-02-01 08:33 出处:网络
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\'.

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

精彩评论

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