Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add image source in Jquery

Tags:

jquery

In my MVC app, the images will b in the App_Data folder. I want to give the source to my img tag in Jquery. Here is how I do it:

var src1 = <%=Url.Content(Server.MapPath("/AppData/1.jpg"))%>
$("#imgLocation").attr("src", src1);

But it doesn't work. Why?

like image 837
petko_stankoski Avatar asked Mar 14 '12 09:03

petko_stankoski


1 Answers

try following:

var src1 = '<%=Url.Content(Server.MapPath("~/AppData/1.jpg"))%>';
$("#imgLocation").attr("src", src1);
like image 137
Nitin S Avatar answered Sep 22 '22 12:09

Nitin S