HOME

Friday, November 24, 2017

Using jquery to move image to different portion of the window

<!Doctype html>
<html>

<head>
<script src="query.min.js"></script>
<script>


$("document").ready(function(){

 $("#move").click(function(){
        $("#image").animate({left: "+=500"}, 2000);
    });

 $("#move2").click(function(){
        $("#image").animate({left: "-=500"}, 2000);
    });

});


</script>
</head>


<body>

<button id="move" > move right </button>
<button id="move2" > move LEFT </button>
<br />
</br />
<img id="image" src="Tulips.jpg" width ="400" height="400" style="position:absolute" />
</body>
</html>


instructions :
1. download latest jQuery library and save in a folder
2. rename the jQuery file to query.min.js
3. copy paste the codes in notepad and save in the same folder with  .html extention



output




jquery program to change the value or text of a pragraph

 <!Doctype html>
<html>

<head>
<script src="query.min.js"></script>
<script>


$("document").ready(function(){

    $("#btn1").click(function(){
        $("#para1").text("hello text");
    });
     $("#btn2").click(function(){
        $("#para2").text("hello html");
    });
    

});


</script>
</head>


<body>
<p id="para1" > pragraph 1 </p>
<p id="para2" > paragraph 2  </p>
<button id="btn1" > set text </button> || <button id="btn2" > set html </button>
</body>
</html>




 instructions :

1. download latest jQuery library and save in a folder
2. rename the jQuery file to query.min.js
3. copy paste the codes in notepad and save in the same folder with  .html extention