开发者

How to select child tag by closest tag in jQuery

i have select the element in jQuery who used currently clicked. i try parent but that's not worked so i try the closest tag in jQuery

$(this).closest('.posts').children('.cbl h1').html('1')

i try this and it's work fine to selection means i select the tag .cbl h1 successfully. now tell me how i can change the t开发者_开发问答ext to 1.

structure

   <div class='posts'>
    <div class='cbl'>
    </div>
<div><div>$(this) element is here</div></div>
    </div>


You can use .text() method.

Something like

$(this).closest('.posts').children('.cbl h1').text('1');
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜