Last Updated: February 25, 2016
·
717
· paradigmshift

jQuery's .children() vs .find()

Writing a dialog pop-up for a mobile app I'm currently developing, I found that I couldn't get the dialog to update with new content even though the functions were being passed the correct argument.

$header = $page.children( ":jqmData(role=header)" ),
$content = $page.children( ":jqmData(role=content)" )

Changing the method to .find() made everything work as it should:

$header = $page.find( "div:jqmData(role='header')" ),
$content = $page.find( "div:jqmData(role='content')" )

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside