Friday, February 22, 2013

jQuery image change demo

In this demo, only images are changed when users click the 1, 2,3 link while other parts of the website keep unchanged. jUQery html, <img> attr method are used.
<!DOCTYPE html>
<script src=""></script>
    <h1> jQuery image change demo</h1>
<div id="container">
    <img src="" />
<p id="menu">
    <a href="">1</a> |
    <a href="">2</a>|
    <a href="">3</a>
$("#menu a").click(function(){
    $("#container").html($("<img>").attr("src", this.href));;
    return false;

Demo: click link 1, 2,3 to see images changed.

jQuery image change demo

No comments:

Post a Comment