Lor*_*ion 2 html javascript jquery
我使用这个jQuery代码来检测表中的点击行.
$('#availableApps').on('click', 'tr', function (e) {
$(this)
});
Run Code Online (Sandbox Code Playgroud)
HTML标记:
<tr>
<td><img src="http://is5.mzstatic.com/image/thumb/Purple/v4/9a/b5/39/9ab539fb-4a39-c780-e9ec-eb58f4685141/source/512x512bb.jpg" style="width:20px; height:20px; border-radius: 10px;"></td>
<td>Lär dig läsa</td>
<td>2<img class="pull-right" src="/Images/arrowRight.png"></td>
</tr>
Run Code Online (Sandbox Code Playgroud)
现在在点击我想改变src最后的图像,<td>我怎么能用这个$(this)对象做这个?
使用find('td:last img')得到img的最后td,然后改变src使用attr功能,像以下.
$('#availableApps').on('click', 'tr', function (e) {
$(this).find('td:last img').attr('src', 'new src');
});
Run Code Online (Sandbox Code Playgroud)