I have made a small plugin which checks to see if a element(s) background image has loaded.
In doing this I needed to extract the URL of the background image, I have managed to do it when there is just one background image:
var bgURL = $('#myelement').css('background-image').replace(/^url\(["']?/, '').replace(/["']?\)$/, '');
However I want to make my plugin support elements with multiple background images
Here is a code pen example of the code in action if it helps.
It would be good if it worked for any css format e.g. both:
background-image: url(sheep.png), url(betweengrassandsky.png);
background-position: center bottom, left top;
background-repeat: no-repeat;
and
background: url(sheep.png) center bottom no-repeat, url(betweengrassandsky.png) left top no-repeat;
Ideally the result would be an array of the urls (e.g. 0 => ['sheep.png'], 1 =>['betweengrassandsky.png'])
Thanks in advance guys.
,and run your regex on each in the array.