Search code examples
jqueryhtmlchildren

jquery children - not found


I'm trying to develop simple abalone game using html5/jquery but I discovered the problem I can't exmplain to myself.

There is a board, which is drawn by jquery and also some moveable balls (also drawn by jquery)

I'd like to send ajax request to the server based on current DOM structure.

I have source code (from firebug) like this: (it's the tile with some id, including some image and maybe the ball)

<div class="tile ui-droppable" id="tile0-5" style="position: absolute; top: 364px; left: 0px; width: 72px; height: 72px;">
    <img src="/abalone/www/images/tile.png" width="72" height="72" alt="tile">
    <img class="ball white-ball ui-draggable" src="/abalone/www/images/white-ball.png" width="36" height="36" alt="white-ball" id="ball0-5" style="position: absolute; top: 18px; left: 18px; z-index: 99999;">
</div>

so assuming id of the tile being tile0-5 I try to write into console (but niether regular script works)

$("#tile0-5").children()

I have expected both images - tile and the ball, but only the tile was returned. I already try to add selector like

$("#tile0-5").children(".ball")

which returned empty array (I mean no result)

this is the last problem I face, can some help me please? I use the most recent jquery stable release

thanks a lot, guys

EDIT: I also tried

    $("#tile0-5").find(".ball")

which also didn't work.


Solution

  • This one also more Helpful!!!

    $("#tile0-5 .ball")
    

    Output contains a list of elements which have ball class in tile0-5 Id Container