# Other Languages > jQuery >  how to display image in html table uisng jquery

## ERUM

i have following line of code along with gif image ..it showing all database driven data but not image 

any help 



```
 for (var i = 0; i < data.d.length; i++) {
 
 $("#tbl").append("<tr  bgcolor= lightblue><td>" + (data.d[i].CustomerID) + "</td><td>" + (data.d[i].CompanyName) + "</td>" + "<td> <img  src=" +  "'" + "detail.gif" +"'" + "height=20 width=20>  </td>" +  "</tr>");
```

----------


## ERUM

solved using this 

  for (var i = 0; i < data.d.length; i++) {

 $("#tbl").append("<tr  bgcolor= lightblue><td>" + (data.d[i].CustomerID) + "</td><td>" + (data.d[i].CompanyName) + "</td>" + "<td> <img  src=" +  "'" + "detail.gif" +"'" + "height=50 width=50>  </td>" +  "</tr>");

----------


## ERUM

I WANT TO open div when href is clicked in loop



```
  for (var i = 0; i < data.d.length; i++) {
 
// var newRow =  $("#tbl").append("<tr  bgcolor= lightblue><td>" + (data.d[i].CustomerID) + "</td><td>" + (data.d[i].CompanyName) + "</td>" + "<td> <img   src=" +  "'" + "detail.gif" +"'" +  "id=" + "'" +"imgSmile" +"'" + "height=50 width=50>  </td>" +  "</tr>");
var newRow =  $("#tbl").append("<tr  bgcolor= lightblue><td>" + (data.d[i].CustomerID) + "</td><td>" + (data.d[i].CompanyName) + "</td>" + "<td><a href=#> <img   src=" +  "'" + "detail.gif" +"'" +  "id=" + "'" +"imgSmile" +"'" + "height=50 width=50></a>  </td>" +  "</tr>");
```

how to do this ..i.e for each row I need to open div whne image is clicked ????????????????????

----------


## Sherin

Try  this query


```
function(response) {
        var trHTML = '';
        $.each(response, function (i, item) {
            var img1 = '<a href="' + item.url1 + '"><img src="' + item.url1 + '"/></a>';
            var img2 = '<a href="' + item.url2 + '"><img src="' + item.url2 + '"/></a>';

            trHTML += '<tr><td>' + item.score + '</td><td>' + img1 + '</td><td>' + img2 + '</td></tr>';
        });
            // append results to table
            $('#resultsTable').append(trHTML);
      }
```

----------


## techgnome

Three things:
1) The amount of quotes you used in your jquery for the image is excessive...
this


```
+ "<td> <img src=" + "'" + "detail.gif" +"'" + "height=50 width=50> </td>" + "</tr>");
```

should just be:


```
+ "<td> <img src='detail.gif' height=50 width=50> </td>" + "</tr>");
```

See how much easier that is to read?

2) There's no need to use 20 question marks when one would have been sufficient. Also, a period would have been more appropriate since it was a statement, not an actual question.

3) Te question about the div and image clicking are a completely different question and should have been in a new thread.

4) Yes, I'm feeling a bit snarky and pedantic today, I haven't had my coffee yet.

5) Yes, I realize that's more tan thee things.

6) No I can't count, I thought that would be obvious by now.

7) Help me! I can't stop making lists.

8) eight s a nice round number, so this will assuage my OCD.


-tg

----------

