Selecting class with jquery

0

What's the difference in selecting the class of these two ways in JQUERY ?

One has access to parameters, another does not, how does it work?

var valor = $(".classe");
var valorAnime = 'classe';

Take a look at this code:

 (function(){
 let $target =$(".projeto"),
    animeStart = 'projeto-anime',
    offset = $(window).height() * 3/4;

    function animeScroll (){
        let documentTop = $(document).scrollTop();

        $target.each(function(){
            let itemTop = $(this).offset().top;

            if( documentTop > itemTop - offset) {
                $(this).addClass(animeStart);
            } else {
                $(this).removeClass(animeStart);
            }
        }) 
    }

 animeScroll();

 $(document).scroll(function(){
     animeScroll();

 });
 }()); 
    
asked by anonymous 24.06.2017 / 16:21

1 answer

0

From my point of view, when you do

var valor = $(".classe");

You are looking at the object whose class corresponds to classe , when you use this code.

var valorAnime = 'classe';

You are assigning the variable valorAnime a string whose content is class

EDIT:

Well this second code of yours does the following thing;

let $target =$(".projeto"),

24.06.2017 / 16:46