2

When using this script the console returns an error "SyntaxError: missing } after property list" How do I pass vscroll variable into .css.

<script type="text/javascript">
        jQuery(window).scroll(function(){
            var vscroll = jQuery(this).scrollTop();
            jQuery('#logotext').css({
                "transform": "translate(0px, "vscroll/2+"px)"
            });
        });  
    </script>
3
  • 1
    You miss a +. Commented Apr 18, 2018 at 2:04
  • @Hikarunomemory there is a + Commented Apr 18, 2018 at 2:05
  • 2
    "translate(0px, "vscroll/2+"px)" => "translate(0px, "+vscroll/2+"px)" Commented Apr 18, 2018 at 2:07

1 Answer 1

1

You missed adding the + sign before vscroll/2 in your code.

<script type="text/javascript">
    jQuery(window).scroll(function(){
        var vscroll = jQuery(this).scrollTop();
        jQuery('#logotext').css({
            "transform": "translate(0px, "+vscroll/2+"px)"
        });
    });  
</script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.