Published on

How to Dynamically Change Image using JavaScript Or jQuery


We know that almost every web pages in the web is dynamic which means the pages are generated in real-time. Content and Images can be dynamically changed as per out requirements.

So today we are going to see about how to change images in our web page dynamically just like sliders in most blogs..

We can pretty easily do it using JavaScript or jQuery.

Here's is an simple example for it.

// JavaScript
document.getElementById('imageID').src = 'new-image.jpg';

// jQuery
$('#imageID').attr('src', 'new-image.jpg');

Got some other easy way to do it ?

Have some problem to implement it ?

Let us know your thoughts in the comment below..