如何使用javascript从'style'属性中获取“width”,“height”和“background-image”值?
<div id="someid" class="someclass" style="width: 100px; height: 100px; background-image: url(https://some image.jpg);">
答案 0 :(得分:2)
您可以获得如下属性:
// To get width
$('#someid').css('width');
// To get height
$('#someid').css('height');
// To get background-image
$('#someid').css('background-image');
答案 1 :(得分:1)
JavaScript:
x.style.width;
x.style.height;
x.style.background-image;
的Jquery:
$('#x').css('width');
$('#x').css('height');
$('#x').css('background-image');