0

How can I get the "width","height" and "background-image" values from the 'style' attribute using javascript ?

<div id="someid" class="someclass" style="width: 100px; height: 100px; background-image: url(https://some image.jpg);">

2 Answers 2

2

You can get properties like so:

// To get width
$('#someid').css('width');
// To get height
$('#someid').css('height');
// To get background-image
$('#someid').css('background-image');
Sign up to request clarification or add additional context in comments.

Comments

1

JavaScript :
x.style.width;
x.style.height;
x.style.background-image;

Jquery:
$('#x').css('width');
$('#x').css('height');
$('#x').css('background-image');

Comments