javascript - How to use jQuery variable in css? -


how can use value stored in var height, value on margin-top?

<script>     $(document).ready(function(){       var height = $(window).height() / 2;        $("a").click(function(){          $("#loader").css({"margin-top:", ***height});        });      }); </script> 

thanks in advance...

like this:

<script>     $(document).ready(function(){       var height = $(window).height() / 2;        $("a").click(function(){          $("#loader").css('margin-top', height+'px');        });      }); </script> 

demo: http://jsfiddle.net/mtejp/


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -