How to get the CSS left-property value of a div using JavaScript

后端 未结 4 930
攒了一身酷
攒了一身酷 2021-01-04 02:19

My CSS rule looks like this:

#my-div{
    display: none;
    position: absolute;
    left: -160px;
    bottom: -150px         


        
4条回答
  •  孤城傲影
    2021-01-04 02:53

    Maybe you have to call your functions after document ready.

    If you use jQuery you can find left value faster:

     $(document).ready(function() {
         var $left = $('#my-div').css('left');
         console.log($left);
     });
    

提交回复
热议问题