0

I want to change an image src which is jsp page through jquery. my code is right below

$('#image').attr("src","file:///D:/vow/themes/multiflex/webapp/multiflex/images/chart.png");

In JSP File I Have

<table>
<tr style="padding-bottom:5px;">
<td>&nbsp;&nbsp;Image &nbsp;&nbsp;</td>
<td>&nbsp;<img id="image"/></td>
<td>&nbsp;</td>
</tr>
</table>

But i see no display on my jsp page after i run.I have my source code and image are in different directories.

Shankar
  • 13
  • 1
  • 6

2 Answers2

1

I think because D would be seen the D drive on the client pc, it wont let you. And if it could do this, it would be a big security hole.

See below link

src absolute path problem

Try relative path like

$("#image").attr("src", "/images/chart.png");
Community
  • 1
  • 1
Swapnil Patil
  • 971
  • 2
  • 18
  • 41
-2

you use src attribute, try specifying the src with the image to identify it on a html page:

$('img[src="your-current-image-src"]').attr('src','your-new-src');

and make sure 'file:///' wont work you need some sort of url or relative path

Umang Mehta
  • 1,467
  • 11
  • 16