how to restore to original CSS


Tags: javascript,jquery,css

Problem :

The site is this: http://roobvillalobos.ga/

I change the CSS with this code:

<script>
  $(window).scroll(function(){
     { $(".numero").css("display", "none"); }
     { $(".subtitulo").css("font-size", "1em"); }
     { $("h1").css("font-size", "1.3em"); }
 });
</script>

But I don´t know how restore to the original CSS when I be on top again



Solution :

Just set it to an empty string again, and it will use the CSS stylesheet.

$(window).scroll(function(){
    var topDistance = $(this).scrollTop();
    if (topDistance == 0) {
        $(".numero").css("display", ""); 
        $(".subtitulo").css("font-size", ""); 
        $("h1").css("font-size", "");
    }
});

Of course, this assumes that these elements did not have any inline styles before you messed with them. Otherwise, you'll have to keep them in a variable and re-apply them later.


    CSS Howto..

    How to change CSS pseudo-class element using JavaScript

    How to merge CSS classes?

    how to make drag and drop jquery?

    How to make this styling with css

    How to adjust table or content in CSS when printing?

    how to disable drupal7 system css files?

    How can I center a div

    How to vertically center text span in fixed position div?

    CSS: How to make the border of a

    tag to be 100 percent on the div tag?

    How to edit HTML with CSS? [closed]

    How to place a color cover on top of an image in CSS

    Styling the placeholder of an input, how can I do this? [duplicate]

    All nested menus show when hovering over menu instead of just the first

    How to have elements with different background-colors yet the background-image shows everywhere (aka, a watermark)?

    How do CSS radio tabs work?

    Pesudo Class and Css Role how to apply theme

    how to get background image present in other folder using css?

    how to overwrite RadWindow control CSS classes with mine?

    How to achieve a left and right background split leaving middle div visible?

    how to add hover effect to button using css

    How to use CSS to change icon color

    How do I override a (css) metaclass property using a GreaseMonkey script?

    How to make css background-image a fluid image work in IE

    How to display code blocks with word wrap and line number with jekyll markdown on github-pages

    How To Expand A Textarea To 100% Using CSS Only

    How to control the HTML area to the right?

    Android Crosswalk Project: How to use css?

    CSS media query height greater than width and visa versa (or how to imitate with JavaScript)

    How can i go back, forward and print a (local) WebBrowser1.DocumentText html page that's sourced from my.resorces - vb.net

    How to make links one link per line, only in the footer via css?