Get a CSS value with JavaScript

前端 未结 9 1434
温柔的废话
温柔的废话 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 07:58

    If you set it programmatically you can just call it like a variable (i.e. document.getElementById('image_1').style.top). Otherwise, you can always use jQuery:

    
        
            
    Test

提交回复
热议问题