It's probably simple, but I can't figure it out or word it correctly for search engines. I'm trying not to use jquery where possible for a.performance and b.personal practice.
I am selecting an element
var container = document.getElementById('container');
Then I try to chain this jquery method on it
container.backstretch('url/to/img');
The jquery plugin I'm using is called backstretch.js
Is there an easy way to do this? Or does the answer rely on how the method was written?
Thanks!
Edit:
Console displays this error:
Uncaught TypeError: container.backstretch is not a function
Edit:
$(container).backstretch('url/to/img'); works. But I don't fully understand it. Is this because jQuery needs to create an object to attach the method to?
No sure if there's any performance savings, especially this being an ID selector, but, this is how:
Or simply just use: