What is more efficient?
var container = $("#container");
// 1
var links1 = container.find("a");
// 2
var links2 = $("a", container);
I personally prefer $("a", container)
because it looks better, but are they different in performance?
What is more efficient?
var container = $("#container");
// 1
var links1 = container.find("a");
// 2
var links2 = $("a", container);
I personally prefer $("a", container)
because it looks better, but are they different in performance?
The context selector $("a", container)
is converted to find. find()
will be faster but in most cases this could be ignored. I would go for find()
as its syntax is quite stright forward for me. This post has performance comparison that would help you deciding which one you would use.