var resources = `<p>This component is at least 50% inline styles by volume. I almost left them out, but I decided not to because having them really gives it the desired effect – the modal sits on top of a gray background that obscures everything behind it, and all you can do is click that Close button. If you try out this code you’ll see what I mean.</p>
|
Find src img tag from string with Javascript |
<img alt="Modal in action" src="https://daveceddia.com/images/modal-img.png" style="width:400px" />
<h3>How It Works</h3>
<p>The most important parts here are the first few lines, and the <code>onClick</code> handler.</p>
<p>This bit here is responsible for “showing” or “hiding” the modal:</p>`
var img,
urls = [],
str = resources,
rex = /<img.*?src="([^">]*\/([^">]*?))".*?>/g;
while ( img = rex.exec( str ) ) {
urls.push( img[1] );
}
Good look!!!