I am learning how to make my own jQuery plugins and I'm running into an issue I am not sure why I am seeing. Here is my plugin:
(function($){
$.fn.clipping = function() {
console.log("Offset Width: " + this.offsetWidth);
console.log("Scroll Width: " + this.scrollWidth);
if(this.offsetWidth > this.scrollWidth) {
} else {
}
};
})( jQuery );
Then on document load I have this:
$("#tiles").clipping();
In the console I get this:
Offset Width: undefined
Scroll Width: undefined
Why is this happening? Do I need to do something to make sure it is looking at the exact element by ID that I want it to?