dinotom dinotom - 6 months ago 59
Javascript Question

change asp.net image url with jquery

I'm trying to use jQuery to change an image every 15 seconds so this works in all browsers. I have tried removing this markup and leaving the div empty and using jQuery to change the background-image url>

How can the image url be changed with jQuery

Given this markup;

<div id="logotransitions" runat="server">
<asp:Image ID="Image1" runat="server" ImageAlign="AbsMiddle"
ImageUrl="~/Images/MainLogo_png_270x180.png" />
</div><!--logotransitions -->

Answer

<asp:Image> should be rendered as an tag. Hence you should be able to modify the src property.

$('#logotransitions > img').prop({ src: 'someimage.png' });
Comments