views:

26

answers:

1

Having the following html snippet

<div class="something">
    <p>Some text</p>
</div>
<div class="somethingElse">
    <p>some other text</p>
</div>

I think the following jquery snippets are identical (will have the same result):

$(".something").find("p").css("border", "1px solid red");

$("p", ".something").css("border", "1px solid red");

My question is, whether one snippet is better than the other and should be used

+3  A: 

Both calls are identical. The latter call is translated into the former one. If you want to omit the translation step, use the former one.

Gumbo
Yep, what he said...
Mark Schultheiss
that was fast .. thanks
harpax