How to Change Image Src Attribute Value Using jQuery

To change image source attribute value using jQuery, we make use of attr() function.  Example is given below.

<!DOCTYPE html>
<html>
<head>
<title>jQuery Tutorial </title>

<script src="http://code.jquery.com/jquery-latest.js"></script>

<script type="text/javascript">
 
 //Function to Change Image.
 function ChangeImage(){
    
    $('#myImage').attr('src', 'http://www.fwait.com/wp-content/uploads/2015/11/jquery-115x115.jpg');
 }

</script>
 
</head>
<body>

<input type="button" value="Change Image" onclick="ChangeImage()"/> <br /> <br />
<img id="myImage" src="http://www.fwait.com/wp-content/uploads/2015/11/JavaScript-115x115.png" >
 
</body>
</html>