Hey,
If I do this
var agentInfoBar = {
toggleAgentInfo: $(".toggle-agent-info"),
agentInfo: $(".agent-info")
}
and then make several subsequent references to
agentInfoBar.agentInfo
will I gain the benefit of only making one call to jquery to retrieve that element set?
Absolutely. This is a good thing to do.
Just be aware that if you later change the dom in a way that would make that selector return a different set of elements, the jquery object you hold a reference to will not be automatically updated.
Right, cool thanks, I’ll need to ensure I update any references if they change. Thanks!