Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In jQuery, using the "find' function, what does this expression mean: $(".divName").find('> div')

I understand the "find" function, I'm just not familiar with what '> div' means. Can anyone help?

like image 992
James Avatar asked Dec 23 '22 03:12

James


1 Answers

It means all direct "div" descendants (so without other elements in between)

So, if your HTML is:

<div id="id1">
  <div id="id2">
    <div id="id3">
    </div>
  </div>
</div>

$("#id1").find("div") will return divs "id2" and "id3"

$("#id1").find("> div") will return only div "id2"

like image 141
Philippe Leybaert Avatar answered Jan 18 '23 23:01

Philippe Leybaert