Alfina Alfina - 4 months ago 8
HTML Question

How to change the img src of a td on the closest tr selection and to hover on

My HTML:

<tbody>
<tr>
<td>1</td>
<td>sdh</td>
<td>228285486</td>
<td>06/18/15 17:11:53</td>
<td>07/12/16 08:46:55</td>
<td>5</td>
<td class="open_chat"><img src="img/open.png"/></td>
</tr>
<tr>
<td>2</td>
<td>dsf</td>
<td>2248285486</td>
<td>06/18/15 17:11:53</td>
<td>07/12/16 08:46:55</td>
<td>5</td>
<td><img src="img/open.png"/></td>
</tr>
<tr>
<td>3</td>
<td>sdfhs</td>
<td>2248285486</td>
<td>06/18/15 17:11:53</td>
<td>07/12/16 08:46:55</td>
<td>5</td>
<td><img src="img/open.png"/></td>
</tr>
</tbody>

Answer

Put this code in your script:

$('tr').hover(function(){
   $(this).find('img').attr('src', 'new_src.jpg');
});
Comments