What is the difference between $("*", $("#container1"))
and $("#container2").find("*")
?.
I usually use AA, but not well in that case can be more ultil the odd.
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
<script language="JavaScript">
$(function(){
var endTime = 0, iniTime = 0, counter = 0;
iniTime = (new Date()).getTime();
$("*", $("#container1")).each(function()
{
counter++;
});
endTime = (new Date()).getTime();
$("#result").append("<div>Container enviroment -> "+counter+" "+(endTime-iniTime)+"</div>");
endTime = 0; iniTime = 0; counter = 0;
iniTime = (new Date()).getTime();
$("#container2").find("*").each(function()
{
counter++;
});
endTime = (new Date()).getTime();
$("#result").append("<div>Find method -> "+counter+" "+(endTime-iniTime)+"</div>");
});
</script>
</head>
<body>
<div id="result"></div>
<div id="container1">
<span></span>...
</div>
<div id="container2">
<span></span>...
</div>
</body>
</html>
Result:
IE8
Container enviroment -> 9752 282
Find method -> 9752 296
Chrome 4.0
Container enviroment -> 9752 65
Find method -> 9752 66
Firefox
Container enviroment -> 9752 135
Find method -> 9752 125
Safari
Container enviroment -> 9752 46
Find method -> 9752 51