I know that ID is a faster selector than class in Javascript. But what if I cache the selector? When the selector is cached, would it differ in speed if it’s a class selecto
Just to make sure I'm not missing the mark... I think you mean
and then in jquery your doing:
var $myclass = $('.myclass');
var $myid = $('#myid');
My understanding of jquery is that when creating the vars creating the $myclass is not as fast as creating the $myid... but when you go back to use them later. they will be the same speed.