开发者

add class to the children if parent has a "translate" class and remove "translate" class of the parent after

开发者 https://www.devze.com 2023-02-26 06:10 出处:网络
have any idea for this? example code: &开发者_C百科lt;td> <div class=\"translate\"> <p><span>Hello world</span></p>

have any idea for this?

example code:

&开发者_C百科lt;td>
  <div class="translate">
    <p><span>Hello world</span></p>
    <p><strong>hellow <span>there</span></strong</p>
  </div>
</td>

the output should be

<td>
  <div class="">
    <pclass="translate"><span class="translate">Hello world</span></p>
    <p class="translate"><strong class="translate">hellow <span class="translate">there</span></strong</p>
  </div>
</td>


$(".translate").removeClass("translate").children().addClass("translate");


$("p.translate").removeClass("translate").children().addClass("whatever");
0

精彩评论

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