set background color of class while scrolling and also the class is must in fixed position

user6752695

I need to change the background color of class(backwhitemarq) while scrolling and also the class backwhitemarq is must fixed position?

html code:

<div class="backwhitemarq">
 /*i need to change the background color for this class.*/
 <center> offer of the day</center>
</div>

css code:

.backwhitemarq
{
   background-color: #f6e454;
   padding: 3px;
   border-radius: 3px;
   height: 44px;
   margin-top: 15px;
   position:fixed;   //fixed
   width:100%;
   z-index:100;
}
.spacewww     /*another class for background color*/
{
   background-color:green;
}

javascript code:

<script type="text/javascript"> 
$(window).scroll(function()   /*scroll function for window*/
 {  
     var speedscr =$('backwhitemarq'),
     scroll = $(window).scrollTop();

     if (scroll >= 10)
     {
        speedscr.addClass("spacewww");
     } else 
     {
        speedscr.removeClass("spacewww");
    }
 });
 </script>
Jigarb1992

$(window).scroll(function()   /*scroll function for window*/
 {  
  var speedscr =$('.backwhitemarq');
     var scroll = $(window).scrollTop();

    if (scroll >= 10)
    {
       speedscr.addClass("spacewww");
    } else 
    {
        speedscr.removeClass("spacewww");
    }
 });
body{ height: 10000px; }
  .backwhitemarq
{
background-color: #f6e454;
padding: 3px;
border-radius: 3px;
height: 44px;
margin-top: 15px;
position:fixed;   //fixed
width:100%;
z-index:100;
}
.spacewww     /*another class for background color*/
{
background-color:green;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="backwhitemarq">/*i need to change the background color for this class.*/
 <center> offer of the day</center>
  </div>

I think you forgot to add .(dot) in jquery selector

<script type="text/javascript"> 
$(window).scroll(function()   /*scroll function for window*/
 {  
  var speedscr =$('.backwhitemarq'),
     scroll = $(window).scrollTop();

    if (scroll >= 10)
    {
       speedscr.addClass("spacewww");
    } else 
    {
        speedscr.removeClass("spacewww");
    }
 });
  </script>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

set background color of class while scrolling and also the class is must in fixed position

From Dev

Change background color if position fixed

From Dev

How to disable background content scrolling in position fixed

From Dev

Background scrolling behind position:fixed; on iOS

From Dev

Need to assign each UICollectionViewCell a background color and colors must stay in a specific order even while scrolling

From Dev

CSS position:fixed - background-color disappear

From Dev

JQuery css() selector to set background-color from class

From Dev

Function or class to add subview to Stack view to set background color

From Dev

Add or remove css class after scrolling on fixed element while using fullpage.js

From Dev

"Ghosting" background color of fixed div when scrolling in Chrome

From Dev

Gridview Freezing/Fixed Header loses background color when scrolling

From Dev

Make tvOS tableview row stay in fixed position while scrolling

From Dev

JavaScript to change background color of class

From Dev

changing javascript class background color

From Dev

bootstrap active class background color

From Dev

Position absolute but with fixed scrolling

From Dev

position:fixed class conflicting with this.src

From Dev

Css position fixed is misaligning span class

From Dev

unable to set background color of div with absolute position

From Dev

How to set my toolbar fixed while scrolling android

From Dev

Body background-color won't change while scrolling

From Dev

Background color switching to transparent while scrolling in WebKit browsers

From Dev

Body background-color won't change while scrolling

From Dev

position: fixed with background image?

From Dev

CSS Background-Position not working in .class

From Dev

To be a key of an NSDictionary, must a class also implement isEqual: and hash?

From Dev

#sidebar position:fixed at certain scrolling

From Dev

Background Image not remaining fixed on scrolling

From Dev

How to set an element's background-color to the value of that element's class name?

Related Related

  1. 1

    set background color of class while scrolling and also the class is must in fixed position

  2. 2

    Change background color if position fixed

  3. 3

    How to disable background content scrolling in position fixed

  4. 4

    Background scrolling behind position:fixed; on iOS

  5. 5

    Need to assign each UICollectionViewCell a background color and colors must stay in a specific order even while scrolling

  6. 6

    CSS position:fixed - background-color disappear

  7. 7

    JQuery css() selector to set background-color from class

  8. 8

    Function or class to add subview to Stack view to set background color

  9. 9

    Add or remove css class after scrolling on fixed element while using fullpage.js

  10. 10

    "Ghosting" background color of fixed div when scrolling in Chrome

  11. 11

    Gridview Freezing/Fixed Header loses background color when scrolling

  12. 12

    Make tvOS tableview row stay in fixed position while scrolling

  13. 13

    JavaScript to change background color of class

  14. 14

    changing javascript class background color

  15. 15

    bootstrap active class background color

  16. 16

    Position absolute but with fixed scrolling

  17. 17

    position:fixed class conflicting with this.src

  18. 18

    Css position fixed is misaligning span class

  19. 19

    unable to set background color of div with absolute position

  20. 20

    How to set my toolbar fixed while scrolling android

  21. 21

    Body background-color won't change while scrolling

  22. 22

    Background color switching to transparent while scrolling in WebKit browsers

  23. 23

    Body background-color won't change while scrolling

  24. 24

    position: fixed with background image?

  25. 25

    CSS Background-Position not working in .class

  26. 26

    To be a key of an NSDictionary, must a class also implement isEqual: and hash?

  27. 27

    #sidebar position:fixed at certain scrolling

  28. 28

    Background Image not remaining fixed on scrolling

  29. 29

    How to set an element's background-color to the value of that element's class name?

HotTag

Archive