- Animation Example
<html>
<head>
http://jquery.js
$(document).ready(function(){
$(“button”).click(function(){
$(“div”).animate({height:300,width:300},”slow”);
$(“div”).animate({height:100,width:100},”slow”);
$(“div”).animate({height:300,width:300},”slow”);
$(“div”).animate({height:100,width:100},”slow”);
});
});
</head>
<body>
<button>Start Animation</button>
<br /><br />
</body>
</html>
1)
<!doctype html>
<head>
<!– Don’t –>
http://code.jquery.com/jquery-2.1.4.min.js
</head>
<body>
<style type=”text/css”>
.b
{
color:red;
}
.s
{
color:green;
}
</style>
$(function()
{
$(“#bb”).css(“font-size”,”35px”);
$(“#bb”).css(“color”,”orenge”);
});
<button id=”bb” class=”b”>button1</button>
<button class=”s”>button2</button>
</body>
2) example -2
<!doctype html>
<head>
…
<!– Don’t –>
http://code.jquery.com/jquery-2.1.4.min.js
</head>
<body>
<style type=”text/css”>
.b
{
color:red;
}
.s
{
color:green;
}
#display{
width:400px;
height: 100px;
border: 1px dashed gray;
}
</style>
$(function()
{
$(“#submit”).click(
function(){
var txt=$(“#text”).val();
$(“#display”).html(txt);
$(“#text”).html(“”);
});
$(“#remove”).click(function()
{
$(“#display”).html(“”);;
});
});
<input id=”text” type=”text”>
<!– <input id=”submit” type=”submit” value=”submit”> –>
<button id=”submit”>submit</button><br>
<button id=”remove”>remove</button><br>
</body>
4) example-4
<!doctype html>
<head>
<!– Don’t –>
http://code.jquery.com/jquery-2.1.4.min.js
<style type=”text/css”>
body {
margin: 0;
}
#hd {
top: 10px;
height: 40px;
width: 100%;
background-color: gray;
}
#hd>h1 {
padding: 5px;
width: 1025px;
margin: 0px auto;
color: white;
}
#container {
margin: 0px auto;
width: 1025px;
min-height: 500px;
margin-top: 10px;
border: 1px solid gray
}
#area {
margin: 0px auto;
width: 1025px;
}
#txtarea {
width: 965px;
height: 27px;
}
#send {
height: 30px;
position: absolute;
}
</style>
</head>
<body>
HOME DATA
Send
</body>
</html>
5) example -5
note –> when we r subminting from text box it will store in on container div(border: 1px solid gray)
$(function() {
$(“#send”).click(
function() {
var data = $(“#txtarea”).val();
$(“#container”).html(data);
$(“#txtarea”).val(“”);
})
});
keypress event
<!doctype html>
<head>
<!– Don’t –>
http://code.jquery.com/jquery-2.1.4.min.js
<style type=”text/css”>
body {
margin: 0;
}
#hd {
top: 10px;
height: 40px;
width: 100%;
background-color: gray;
}
#hd>h1 {
padding: 5px;
width: 1025px;
margin: 0px auto;
color: white;
}
#container {
margin: 0px auto;
width: 1025px;
min-height: 500px;
margin-top: 10px;
border: 1px solid gray
}
#area {
margin: 0px auto;
width: 1025px;
}
#txtarea {
width: 965px;
height: 27px;
}
#send {
height: 30px;
position: absolute;
}
</style>
/* $(function() {
$(“#send”).click(
function() {
var data = $(“#txtarea”).val();
$(“#container”).html(data);
$(“#txtarea”).val(“”);
})
}); */
$(function() {
$(“#txtarea”).keypress(function(event) {
/* if( event.which == 13)
{ */
if ($(“#enter”).prop(“checked”)) {
console.log(“enter press,console…………”);
event.preventDefault();
}
/* } */
});
});
</head>
<body>
HOME DATA
Send
click to
send
</body>
</html>
6) example -6
adding user ————–name
<!doctype html>
<head>
<!– Don’t –>
http://code.jquery.com/jquery-2.1.4.min.js
<style type=”text/css”>
body {
margin: 0;
}
#hd {
top: 10px;
height: 40px;
width: 100%;
background-color: gray;
}
#hd>h1 {
padding: 5px;
width: 1025px;
margin: 0px auto;
color: white;
}
#container {
margin: 0px auto;
width: 1025px;
height: 500px;
margin-top: 10px;
border: 1px solid gray;
overflow: scroll;
}
#area {
margin: 0px auto;
width: 1025px;
}
#txtarea {
width: 965px;
height: 27px;
}
#send {
height: 30px;
position: absolute;
}
.user {
color: red;
}
</style>
$(function() {
$(“#txtarea”).keypress(function(event) {
if (event.which == 13) {
if ($(“#enter”).prop(“checked”)) {
//$(“#txtarea”).val(“”);
$(“#send”).click();
event.preventDefault();
}
}
});
$(“#send”).click(
function() {
var uname = “ YOU :“;
var newdata = $(“#txtarea”).val();
var previousmsg = $(“#container”).html();
if (previousmsg.length > 0) {
previousmsg = previousmsg + “
”
}
$(“#container”).html(previousmsg + uname + newdata);
$(“#txtarea”).val(“”);
});
});
</head>
<body>
HOME DATA
Send
click to
send
</body>
</html>
example -7
Chat Box
<!doctype html>
<head>
<!– Don’t –>
http://code.jquery.com/jquery-2.1.4.min.js
<style type=”text/css”>
body {
margin: 0;
}
#hd {
top: 10px;
height: 40px;
width: 100%;
background-color: gray;
}
#hd>h1 {
padding: 5px;
width: 1025px;
margin: 0px auto;
color: white;
}
#container {
margin: 0px auto;
width: 1025px;
height: 500px;
margin-top: 10px;
border: 1px solid gray;
overflow: scroll;
}
#area {
margin: 0px auto;
width: 1025px;
}
#txtarea {
width: 965px;
height: 27px;
}
#send {
height: 30px;
position: absolute;
}
.bot {
color: red;
}
.user {
color: green
}
</style>
var user=””;
function send_msg(msg) {
$(“#container”).html(“chatbot: ” + msg);
}
function usern() {
send_msg(“What is ur Name”);
}
function ai(msg)
{
if(user.length=>0)
user=msg;
send_msg(“Hello, ” +user+” How r u”);
}
$(function() {
usern();
$(“#txtarea”).keypress(function(event) {
if (event.which == 13) {
if ($(“#enter”).prop(“checked”)) {
//$(“#txtarea”).val(“”);
$(“#send”).click();
event.preventDefault();
}
}
});
$(“#send”).click(
function() {
var uname = “ YOU :“;
var newdata = $(“#txtarea”).val();
var previousmsg = $(“#container”).html();
if (previousmsg.length > 0) {
previousmsg = previousmsg + “
”
}
$(“#container”).html(previousmsg + uname + newdata);
ai(newdata);
$(“#txtarea”).val(“”);
});
});
</head>
<body>
HOME DATA
Send
click to
send
</body>
</html>
example-8
————————–portpolio style—————————
html
……………….
<html>
<head>
<title>PORTFoLIO</title>
<link rel=”stylesheet” type=”text/css” href=”css/projectstyle.css”>
https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js
http://js/projectscript.js
</head>
<body>
</div>
</body>
</html>
example-8
css
………..
body {
margin: 0px;
padding: 0px;
font-style: italic;
}
#header {
width: 100%;
height: 56px;
background-color: black;
}
#menu {
color: white;
}
h2 {
margin: 5px;
}
#wrapper {
width: 1024px;
min-height: 500px;
margin: :0px auto;
margin-left: 100px;
}
#portfolio {
list-style-type: none;
padding-left: 0px;
}
#portfolio li {
display: inline-block;
margin: 10px 5px 10px 5px;
}
#portfolio li img {
width: 240px;
}
#overlap {
display: none;
width: 100%;
height: 100%;
position: fixed;
background-color: black;
opacity: 0.7;
}
#frame {
display: none;
top: 50px;
position: fixed;
background-color: white;
width: 520px;
height: 450px;
left: 25%;
}
#frame img {
width: 450px;
height: 400px;
}
#frame img:hover {
cursor: pointer;
}
#overlap:hover {
cursor: pointer;
}
#portfolio:hover {
cursor: pointer;
}
js file
………..
$(function() {
$(“#portfolio img”).click(function() {
var src = $(this).attr(“src”);
$(“#frame img”).attr(“src”, src);
var fade = $(“#frame”).fadeIn();
$(“#overlap”).fadeIn();
});
$(“#overlap”).click(function() {
$(this).fadeOut();
$(“#frame”).fadeOut();
});
});
……………………………………………………………………………………………………………………………………………………………………………………………………………………………. narrow moving images(next, previous images)……………………………………………….
html
………
<html>
<head>
<title>PORTFoLIO</title>
<link rel=”stylesheet” type=”text/css” href=”css/projectstyle.css”>
https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js
http://js/projectscript.js
</head>
<body>
</div>
</body>
</html>
example -9
css
………..
body
{
margin: 0px;
padding: 0px;
font-style: italic;
}
#header
{
width:100%;
height: 56px;
background-color: black;
}
#menu{
color:white;
}
h2{
margin: 5px;
}
#wrapper
{
width:1024px;
min-height: 500px;
margin: :0px auto;
margin-left: 100px;
}
#portfolio{
list-style-type:none;
padding-left: 0px;
}
#portfolio li{
display: inline-block;
margin: 10px 5px 10px 5px;
}
#portfolio li img{
width: 240px;
}
#overlap
{
display:none;
width: 100%;
height: 100%;
position:fixed;
background-color: black;
opacity:0.7;
}
#frame
{
display:none;
top:50px;
position:fixed;
background-color: white;
width: 520px;
height: 450px;
left: 25%;
}
#main
{
width: 450px;
height: 400px;
}
#frame img:hover
{
cursor:pointer;
}
#overlap:hover
{
cursor:pointer;
}
#portfolio:hover
{
cursor:pointer;
}
#left img
{
width:30px;
height:30px;
margin-left:150px;
opacity:0.5;
}
#right img
{
width:30px;
height:30px;
margin-left:150px;
opacity:0.5;
}
#table1-frame{
position:absolute;
}
js file
……………..
$(function() {
var current_li;
var prev_li;
$(“#portfolio img”).click(function() {
var src = $(this).attr(“src”);
current_li = $(this).parent();
prev_li = $(this).parent();
$(“#main”).attr(“src”, src);
var fade = $(“#frame”).fadeIn();
$(“#overlap”).fadeIn();
});
$(“#overlap”).click(function() {
$(this).fadeOut();
$(“#frame”).fadeOut();
});
$(“#right”).click(function() {
if (current_li.is(‘:last-child’)) {
var next_li = $(“#portfolio li”).first();
} else {
var next_li = current_li.next();
}
var next_src = next_li.children(“img”).attr(“src”);
$(“#main”).attr(“src”, next_src);
current_li = next_li;
});
$(“#left”).click(function() {
if (prev_li.is(‘:first-child’)) {
prev_li = $(“#portfolio li”).last();
} else
previous_li = prev_li.prev();
previous_li = prev_li.prev();
var prev_src = previous_li.children(“img”).attr(“src”);
$(“#main”).attr(“src”, prev_src);
prev_li = previous_li;
});
});
js for mousehover and mouseleave
……………………………..
$(function() {
var current_li;
var prev_li;
$(“#portfolio img”).click(function() {
var src = $(this).attr(“src”);
current_li = $(this).parent();
prev_li = $(this).parent();
$(“#main”).attr(“src”, src);
var fade = $(“#frame”).fadeIn();
$(“#overlap”).fadeIn();
});
$(“#overlap”).click(function() {
$(this).fadeOut();
$(“#frame”).fadeOut();
});
$(“#right”).click(function() {
if (current_li.is(‘:last-child’)) {
var next_li = $(“#portfolio li”).first();
} else {
var next_li = current_li.next();
}
var next_src = next_li.children(“img”).attr(“src”);
$(“#main”).attr(“src”, next_src);
current_li = next_li;
});
$(“#left”).click(function() {
if (prev_li.is(‘:first-child’)) {
prev_li = $(“#portfolio li”).last();
} else
previous_li = prev_li.prev();
previous_li = prev_li.prev();
var prev_src = previous_li.children(“img”).attr(“src”);
$(“#main”).attr(“src”, prev_src);
prev_li = previous_li;
});
$(“#left , #right”).mouseover(function() {
$(this).css(“opacity”, “2”);
});
$(“#left , #right”).mouseleave(function() {
$(this).css(“opacity”, “0.5”);
});
});