Reputation:
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);">
Upvotes: 0
Views: 75
Reputation: 5036
JavaScript :
x.style.width;
x.style.height;
x.style.background-image;
Jquery:
$('#x').css('width');
$('#x').css('height');
$('#x').css('background-image');
Upvotes: 1
Reputation: 1909
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');
Upvotes: 2