.offset() >>> Uncaught TypeError: undefined is not a function
I am getting an an error when I try and use certain jquery functions.
I presume I don't have some js file included that I actually need... but I can't tell what it is (after much googling)...
My code fails when I call
requiredFields[i].offset(). It finds the object and gives me the offsetLeft and offsetTop perfectly well... it just seems to be certain functions that I would expect to be available.
-
$(function () {
var requiredFields = $.find("[data-val-required]");
var page = $.find("div#page")[0];
console.log(page);
for (var i = 0; i < requiredFields.length ; i++) {
var left = requiredFields[i].offsetLeft;
var top = requiredFields[i].offsetTop;
console.log(requiredFields[i].offset())
var t = $("<div />");
t.css("left", (left - 16) + "px");
t.css("top", (top - 16) + "px");
t.css("width", "16px");
t.css("height", "16px");
t.css("background-color", "red");
page.append(t);
}
})
-