How to get the children of the $(this) selector?

前端 未结 18 2396
日久生厌
日久生厌 2020-11-22 05:10

I have a layout similar to this:

and would like to use a jQuery selector to selec

18条回答
  •  梦如初夏
    2020-11-22 05:33

    Ways to refer to a child in jQuery. I summarized it in the following jQuery:

    $(this).find("img"); // any img tag child or grandchild etc...   
    $(this).children("img"); //any img tag child that is direct descendant 
    $(this).find("img:first") //any img tag first child or first grandchild etc...
    $(this).children("img:first") //the first img tag  child that is direct descendant 
    $(this).children("img:nth-child(1)") //the img is first direct descendant child
    $(this).next(); //the img is first direct descendant child
    

提交回复
热议问题