1
I’m not very good yet of regular expression. How could I do to capture only the contents present within the snippet url()
of background-image
?
Example:
$elemento.css('background-image'); // "url(imagem.png)"
Or else:
$element.css('background-image'); // "url(imagem.png), url(imagem2.png)"
I need to return, by pure Javascript or jQuery, the following for the cases:
['imagem.png']
['imagem.png', 'imagem2.png']
How to make a regular expression to capture this?
And when there’s two
url()
? So I spoke of regular expression, because I knew it would not be a simple replace.– Wallace Maxters
@ do you want to take all the url’s of the background-image and put in an array ? do you want to do this when loading the page ?
– Gabriel Rodrigues
Yes, I want to return them all in an array. Mount an array with these urls. Because if you have one, take one. If you have more than one, take them too.
– Wallace Maxters
@Wallacemaxters as will be different bg’s I added two div’s and 2 bg’s different to exemplify, give a look at the return...
– Gabriel Rodrigues
I think you misunderstood when you said "two url()attributes". See what can be done in css:
background-image: url(1.png), url(2.png), url(3.png);
. I want to return['1.png', '2.png', '3.png']
– Wallace Maxters
You just want to name the image.format without her path ?
– Gabriel Rodrigues