LF.JRY LF.JRY - 2 months ago 10
CSS Question

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

Trying to change the source of an image with JavaScript or jQuery. Its not possible for us to change the source of the file or to replace the image itself. The table is created programmatically.

Problem is that the image or the

<td>
that contains the image inside as no ID tags. The only thing that the
<td>
has is the
alt=”selected”
tag. I want to change the source of the image inside the
<td>
that has its
alt=“selected”
.

this is my handicap try that didn’t work.

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


Any help is much appreciated

Answer

try this :

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