I want to add to div#container a div inside another div and then get selector of the inner div. Which one is the better way to do this?
$('#container').html("<div><div class='get'></div></div>");
var div = $('#container').find('.get');
or
var div = $('<div></div>');
$('#container').html(
$('<div></div>').html(div)
);
The latter. In the first example you are traversing a lot more (because of the
find) than in the second example, which has some performance implications.