image swaping using jquery

Images swapping using jquery

Create a new project in visual studio and make a simple ActionController and its corresponding view

View Code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$('img[id$=imageSwap]').toggle(
function() {
$(this).attr("src", "../images/Hide.gif");
},
function() {
$(this).attr("src", "../images/Show.gif");
}
);
});
</script>

<h2>Click on the image to swap</h2>
<br />
<img id="imageSwap" src="~/images/Show.gif"/>

For more jquery snippets please visit Jquery section