Get a CSS value with JavaScript

前端 未结 9 1433
温柔的废话
温柔的废话 2020-11-21 07:55

I know I can set a CSS value through JavaScript such as:

document.getElementById(\'image_1\').style.top = \'100px\';

But, can I

9条回答
  •  借酒劲吻你
    2020-11-21 08:04

    Use the following. It helped me.

    document.getElementById('image_1').offsetTop
    

    See also Get Styles.

提交回复
热议问题