Reputation: 239
I would like to build a list of articles with a different thumbnail for each one, and this thumbnail should be loaded using jquery.load, but I have one problem:
The class of each article's thumbnail in html is as follows:
thumb{ARTICLE_ID}
Now, given this basic example:
<i class="thumb{ARTICLE_ID}"></i>
<script>$('thumb{ARTICLE_ID}').load("https://somewebsites.com .itemimg");</script>
How can I Make jQuery parse "{ARTICLE_ID}" variable?
Thank you.
Upvotes: 0
Views: 35
Reputation:
You can achieve it this way, for example:
<i class="thumbnail" data-article-id="{ARTICLE_ID}"></i>
<script>
$('.thumbnail').each(function () {
$(this).load("https://somewebsites.com/" + $(this).data('article-id'))
})
</script>
Upvotes: 1