更改图像的来源,在<alt= " selected ".图像没有ID标签

Change the source of the image inside the <td> that has alt=“selected”. Image has no ID tag

本文关键字:图像 alt selected 标签 ID      更新时间:2023-09-26

尝试使用JavaScript或jQuery更改图像的来源。我们不可能改变文件的来源或替换图像本身。表以编程方式创建。

问题是图像或<td>中包含的图像作为没有ID标签。<td>唯一拥有的就是alt=”selected”标签。我想改变<td>中有alt=“selected”的图像的来源。

这是我的障碍尝试,没有工作。

HTML:

<td class="ms-vb2">
   <img border="0" align="absmiddle" style="cursor: hand" src="/_layouts/images/rbsel.gif" alt="Selected">
</td>
JQUERY:

$("img[alt='selected']").src( "http://myimage.png" );

任何帮助都非常感谢

try this:

$( "img[alt='selected']" ).attr('src',"http://myimage.png" );