user3756781
user3756781

Reputation: 179

Assign an animation to all unordered list except a specific ul

I am using the code below to allow me to fadein a div when I begin to scroll, which is assign to all of my unordered list. Is there a way I can tell the script to not assign this function to a specific ul

Example

I want all UL to fade in but would like ul class"test" to not fade, but to just be static.

 tiles = $("ul li").fadeTo(0, 0);
  $(window).scroll(function(d,h) {
  tiles.each(function(i) {
    a = $(this).offset().top + $(this).height();
    b = $(window).scrollTop() + $(window).height();
    if (a < b) $(this).fadeTo(500,1);
 });
 });

Upvotes: 0

Views: 41

Answers (2)

Scimonster
Scimonster

Reputation: 33409

You can remove items with the .test class from the collection using .not().

tiles = $("ul li").not("ul.test li").fadeTo(0, 0);

Upvotes: 1

Turnip
Turnip

Reputation: 36722

Use the :not() selector

DEMO

tiles = $("ul li:not(.test)").fadeTo(0, 0);
  $(window).scroll(function(d,h) {
  tiles.each(function(i) {
    a = $(this).offset().top + $(this).height();
    b = $(window).scrollTop() + $(window).height();
    if (a < b) $(this).fadeTo(500,1);
 });
 });

Upvotes: 1

Related Questions