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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

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

android - How to create dynamically Fragment pager adapter -