开发者

Does an alternative to .closest() exist?

开发者 https://www.devze.com 2023-01-22 05:24 出处:网络
this is a snippet from my code: $("#myid").append($("p:contains(\'text\')").closest("div").clone());

this is a snippet from my code:

$("#myid").append($("p:contains('text')").closest("div").clone());

I tried to get the first closest ancestor div-element of p containing 'text'.

I开发者_开发技巧'm looking for an alternative to .closest() because I have to use jquery version 1.2.6. Do you have got an idea what I'm looking for?

I hope you can help me. I appreciate every hint, piece of code, etc..


$('p').parents('div:first')

should do :)

0

精彩评论

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