how can you add an ID to a link generated like this?
function addElement(list, pos) {
var linkUrl = productList.products[pos].productLink;
var linkItem = document.createElement('a');
linkItem.setAttribute('href', linkUrl);
The previous code generates the following link
<a href="***/details.page?productId=3"><img src="***/topseller_main_en_1.png"></a>
Try this:
You can also do this in jQuery like this:
Here’s an even shorter way:
Then just append it to an element in the document.