c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
JQuery

Change image src using jQuery

| | JQuery

In this example, I will show you how to change the image src attribute using jquery. The attr (name, value) method is used to set the named attribute, src and value. The following code is used to set the src using jQuery.

<img id="profilePic" src="~/images/hero.jpg" />

 

$("#profilePic").attr("src", "~/images/john.jpg");