Hi
I'm new to jQuery.
I'm writing some code to show a picture if user clicks on table row.
this is the table
<table id="restable" border="0">
<thead><tr>
<th class="cat" width="150"><a href="">Category</a></th>
<th class="brand" width="150"><a href="">Brand</a></th>
<th class="name" width="300"><a href="">Name</a></th>
<th class="weight" width="50"><a href="">Weight</a></th>
</tr></thead>
<tbody id="table">
</tbody>
</table>

The table is filled with this function
function search(sortt,dirt) {
$.getJSON("/jsonsearch.php", {cat: $("select#catselect").val(), brand:
$("select#brandselect").val(), name: $("input#search").val(), sort:
sortt, dir: dirt}, function(j){
      $("tbody#table").empty();
      var row='';
      for (var i = 0; i < j.length; i++) {
        row="<tr><td width='150'>"+j[i].cats+"</td><td width='150'>"+j
[i].brand+"</td><td class='name' width='300'>"+j[i].name+"</td><td
width='50'>"+j[i].weight+"</td></tr>";
        $("#restable tbody").append(row);
      }
    })

This is the function i put inside $(document).ready()
$("#table td").click(function(){
                alert("jhgjgh");
});

The problem is that click event doesn't fire.

One more related question
If i get it working, how do i get the contents of the row that user
clicked. I need Name from that row.

Thank you.

Reply via email to