Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery get children by attribute [closed]

Tags:

jquery

This code is returning an empty array when I run it even though there is a div with the attribute [data-directory] in the container.

$(container).children( '[data-directory]' )

container is valid, and the children are there when I log $(container), I'm not sure why it isn't pulling the child that is there though.

like image 768
Blake A. Nichols Avatar asked Jun 15 '13 23:06

Blake A. Nichols


1 Answers

please check to see whether container is a valid and exists if it does. then probably $(container).find( '[data-directory]' ) would do

.children would only look in the immediate children. where as .find will go through all the descendants which i think is what you want

like image 144
Parv Sharma Avatar answered Oct 16 '22 19:10

Parv Sharma