Home javascript How to get the class of an element, waypoint.js?

How to get the class of an element, waypoint.js?

Author

Date

Category

There is such a code

& lt; div class = "main-elements" & gt;
  & lt; div class = "main-item" & gt; & lt; / div & gt;
  & lt; div class = "main-item" & gt; & lt; / div & gt;
  & lt; div class = "main-item" & gt; & lt; / div & gt;
  & lt; div class = "main-item" & gt; & lt; / div & gt;
  & lt; div class = "main-item" & gt; & lt; / div & gt;
 & lt; / div & gt;

And this js code

$ (". main-item"). waypoint (function () {
  var el = $ (this)
  console.log (el)
 }, {offset: '100%'});

However, console.log does not output the html element itself. How to get exactly the html element in order to add the class to it


Answer 1

You just need to understand the structure of the returned object:

el [0] .element

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions