javascript - get the background image dimension -


i want make design responsive need background image dimension (width, height) using javascript or jquery. ideas ?

<div class="container">     <div id="result" class="result">&nbsp</div>     <div class="slot-container">             <div id="slot1" class="slot"></div>             <div id="slot2" class="slot"></div>             <div id="slot3" class="slot"></div>         <div><button id="control" class="btn">start</button></div>         <div id="try" class="result try">try 0</div>     </div>  </div> 

https://jsfiddle.net/h0fbha33/

$(window).on("load", function () {     var img = new image();     img.src = $('.slot').css('background-image').replace(/.*\s?url\([\'\"]?/, '').replace(/[\'\"]?\).*/, '');     alert( img.width + ' , ' + img.height); }); 

here fiddle link: https://jsfiddle.net/beroza/a01y1me4/


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -