jQuery: How to get to a particular child of a parent?

后端 未结 5 402
迷失自我
迷失自我 2020-12-04 09:23

To give a simplified example, I\'ve got the following block repeated on the page lots of times (it\'s dynamically generated):

&l
5条回答
  •  难免孤独
    2020-12-04 10:05

    This will find the first parent with class box then find the first child class with regex matching something and get the id.

    $(".mylink").closest(".box").find('[class*="something"]').first().attr("id")
    

提交回复
热议问题