Javascript jQuery更改$(此)对象中的html

Javascript jQuery更改$(此)对象中的html,javascript,jquery,html,Javascript,Jquery,Html,我使用这个jQuery代码来检测表中的点击行 $('#availableApps').on('click', 'tr', function (e) { $(this) }); HTML标记: <tr> <td><img src="http://is5.mzstatic.com/image/thumb/Purple/v4/9a/b5/39/9ab539fb-4a39-c780-e9ec-eb58f4685141/source/512x512bb.jpg"

我使用这个jQuery代码来检测表中的点击行

$('#availableApps').on('click', 'tr', function (e) {
    $(this)
});
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>

Lär dig Läsa
2.
现在单击我想更改最后一个
中图像的
src
,如何使用此
$(this)
对象执行此操作

现在单击,我想更改 最后,

由于您希望在单击任何列时更新最后一列的img源,请重试

$(this).siblings().last().find( "img" ).attr( "src" , "new URL" );
解释

到达最后一个同级-
$(this).sibles().last()

找到最后一个同级中的img-
$(this.sibles().last().find(“img”)

最后更新URL

使用find on
$(此)。find
with:last获取最后一个img,并使用
attr
设置
src

$(this).find( "td:last img" ).attr( "src", "new URL" ) ;
尝试使用
.find()
查找
img
,并使用
.attr()
更改src属性,如图所示:-

$('#availableApps').on('click', 'tr', function (e) {
    $(this).find("img.pull-right").attr('src','new src');
});
$('#availableApps').on('click', 'tr', function (e) {
    $(this).find('td:last img.pull-right').attr('src', 'new src');
});
或者使用
:last
查找最后一个td,如图所示:-

$('#availableApps').on('click', 'tr', function (e) {
    $(this).find("img.pull-right").attr('src','new src');
});
$('#availableApps').on('click', 'tr', function (e) {
    $(this).find('td:last img.pull-right').attr('src', 'new src');
});
您可以使用

使用
find('td:last img')
在last
td
中获取
img
,然后使用
attr
函数更改
src
,如下所示

$('#availableApps').on('click', 'tr', function (e) {
    $(this).find('td:last img').attr('src', 'new src');
});

使用
:last
作为last
td

$('#availableApps').on('click', 'tr', function (e) {
    $(this).find('td:last img').attr('src', 'YOUR_NEW_IMAGE_SOURCE');
});
使用并尝试以下代码:-

$(this).find('td:last-child').find('img').attr('src', 'new src');


希望它能帮助您:)

这个
中有多个
图像
元素
您在last()和find('img')之间错过了点(.)。
$(this).find(':last-child').find('img').attr('src', 'new src');