I have a list of articles with a preview feature which does let the user hover the title of the article to have a brief preview of the content, and the structure is as follows:
<img id="{article_id}" src="" /><a href="/something.html" id="{article_id}" data-original-title="https://website.tld/path/image.jpg some other text here">Name of the Article</a>
I need to dynamically take the link to the image (in this example "https://website.tld/path/image.jpg" ) of each of my article previews to fill the empty "img src", knowing that:
- The url of the image is different in each article preview
- The {article_id} is different in each article
Here's a more comprehensive jsfiddle: https://jsfiddle.net/znnytLrf/2/
I was thinking about using a regex to isolate the image url which always appears at the top, which can basically be treat as a word in regex, but I'm getting very confused as I spent my last 48 hours on it without any significant progresses.
How can I achieve this using jquery? If not, or too trivial, do you have some alternative ways to accomplish this?
Thank you so much for reading my question.