Combine image and url in the same column

Combine image and url in the same column

LersterLerster Posts: 21Questions: 5Answers: 0

I want to combine an image and a text link beside of each other in the **same ** column (1). What do I have to change in my code?

I manage to let them appear separately in two coluns. This is my code:

 $('#example').DataTable( {
 "processing": true,
 "serverSide": true,
  ajax": "https://xyyy.com/getData.php",

 "columnDefs": [
{
"targets": 1,    
"render": function ( data, type, row, meta) {
            var itemID = row[0];
            var quality = row[2];
            return '<a href="https://www.xyyy.com/item=' + itemID + '"class="q' + quality + '">' + data + '</a>';

}}, 

{
 "targets" : 1 ,
 "data": "img",
 "render" : function ( url, type, full)
                var iconID = row[3];           
   {
  return '<img height="15%" width="15%" src="https://www.xyyy.com/images//icons/large/' + iconID + '"/>';
  }},

```

This question has an accepted answers - jump to answer

Answers

  • Erwan CuinetErwan Cuinet Posts: 3Questions: 0Answers: 3
    Answer ✓

    Instead of returning a string containing only the <a></a> tag return a string with <a></a> and the <img> one

This discussion has been closed.