Answer the question
In order to leave comments, you need to log in
Why doesn't jquery code work?
I tried to get the width of an element by its "index":
$(".header__navbar-list__link").on("click", function() {
let index = $(".header__navbar-list__link").index(this);
console .log($(".header__navbar-list__link").get(index).width());
});
And output this width to the console.
However, an error occurs in the console:
Uncaught TypeError: $(...).get(...).width is not a function
at HTMLLIElement.<anonymous> (home.js:19)
at HTMLLIElement.dispatch (jquery.min.js:2)
at HTMLLIElement.v.handle (jquery.min.js:2)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question