$("#img1").show(2000);
$("#img2").hide(3000);
$("#img3").toggle(1000);<script>
$(document).ready(function(){
$(#btn1).click(function () {
$("#img1").show(2000);
});
});
</script>
<input type=button id="btn1" value="Start Show"/>
<img id="img1" src="img1.jpg">
<script>
$(document).ready(function(){
$(#btn2).click(function () {
$("#img2").hide(3000);
});
});
</script>
<input type=button id="btn2" value="Start Hide"/>
<img id="img2" src="img2.jpg">
<script>
$(document).ready(function(){
$(#btn3).click(function () {
$("#img3").toggle(1000);
});
});
</script>
<input type=button id="btn3" value="Start Toggle"/>
<img id="img3" src="img3.jpg">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
</script>
<style>
.show_hide
{
box-shadow:1px 1px 5px 2px #6DC83C;
position:relative;
width:448px;
height: 336px;
border-radius:19px;
}
.show_hide img
{
border-radius:19px;
position:absolute;
left:0;
top:0;
}
</style>
<script>
$(function(){
$('.show_hide img:gt(0)').hide();
setInterval(function(){$('.show_hide :first-child').hide(3000).next('img').show(3000).end
().appendTo('.show_hide');}, 6000);
});
</script>
<div class="show_hide">
<img src="img1.JPG" />
<img src="img2.JPG" />
<img src="img3.JPG" />
</div>
$("#animation").fadeIn();
// It fades an element in over 400ms
$("#animation").fadeOut("fast");
// It fade outs over 200ms
$("#animation").fadeIn(5000);
//It fades an element in over 5000ms
jQuery.fx.speeds["medium-fast"]=3000;
jQuery.fx.speeds["medium-slow"]=5000;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
jQuery.fx.speeds["medium-slow"]=3000;
jQuery.fx.speeds["very-slow"]=5000;
$(document).ready(function(){
$("#btn1").click(function(){
$("#animation1").fadeIn();
$("#animation3").fadeIn(5000);
$("#animation5").fadeIn("medium-slow");
});
$("#btn2").click(function(){
$("#animation2").fadeOut("fast");
$("#animation4").fadeOut("very-slow");
});
});
</script>
<input type=button id="btn1" value="Start FadeIn"/><br/>
<div id="animation1" style="display:none;background:pink;">It fades an element in over 400ms</div><br/>
<div id="animation3" style="display:none;background:red">It fades an element in over 5000ms</div><br/>
<div id="animation5" style="display:none;background:yellow">It fades an element in over 3000ms</div><br/>
<input type=button id="btn2" value="Start FadeOut"/><br/>
<div id="animation2" style="background:red">It fade outs over 200ms</div><br/>
<div id="animation4" style="background:pink">It fade outs over 5000ms</div><br/>
<script>
$(document).ready(function(){
$("#btn4").click(function(){
$("#message").fadeIn("fast", function() {$("#message").text("Hello this is animation");});
});});
</script>
<input type=button id="btn4" value="Start Animation"/><br/>
<div id="message" style="color:red"></div>
<script>
$(document).ready(function(){
$("#blinker").mouseover(function(){
$("#blinker").fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn();});
});
</script>
<div id="blinker" style="color:red"><h3>It blinks before fading in permanently</h3></div>
<script>
$(document).ready(function(){
$("#btn3").click(function(){
$("#effect").fadeIn({
duration: "slow",
complete: function(){$(this).text("Animation was completed");}
});});});
</script>
<input type=button id="btn3" value="Start Animation"/>
<div id="effect" style="background:yellow">This is sample animation effect</div>
$("#clr").append("<br/>"+message);
// It adds a content at end of the #clr element
$("h1").prepend(":");
// It adds colon sign at the star of each <h1>
$("h1").before("<hr/>");
// It insert horizontal line before each <h1> element
$("h1").after("<hr/>");
// It insert horizontal line after each <h1> element$("hr").replaceWidth("<br/>");
// It replaces <hr/> elements with <br/>
$("h2").each(function(){
var h2=$(this);
h2.replaceWith("<h1>"+h2.html()+"</h1>");
});
// It replaces <h2> with <h1> keeping the content.
$("<br/>"+message).appendTo("#clr");
// It adds a content at end of the #clr element
$(document.createTextNode(":")).prependTo("h1");
// It adds colon sign at the star of each <h1>
$("<hr/>").insertBefore("h1");
// It insert horizontal line before each <h1> element
$("<hr/>").insertAfter("h1");
// It insert horizontal line after each <h1> element
$("<br/>").replaceAll("hr");
// It replaces <hr/> elements with <br/>
$(document.body).append("<div id="linklist"><h1>List of Links</h1></div>");
//It appends a new div with id "linklist", to the end of the document
$("a").clone().appendTo("#linklist");
//It copy all links in the document and insert them into that new div
$("#linklist>a").after("<br/>");
//It insert <br/> elements after each link so they display on separate lines
$("h1").wrap(document.createElement("i"));
//It produces <i><h1> .....</h1></i>
$("h1").wrapInner("<i/>");
//It produces <h1><i>........</i></h1>
$("body>p:first").wrap("<a name="lead"><div class="first"></div></a>");
// It wraps the first paragraph in one anchor and div
$("body>p:not(:first)").wrapAll("<div class="rest"></div>");
//It wraps all the other paragraps in another div
$("#hide").empty();
// It removes all the contents having id #hide
$("#rmv").remove();
// It removes the contents and events having id #rmv
$("form").attr("action");
// It gets the action attribute from the first form.$("#icon").attr("src", "icon.gif");
// It sets the src attributes for image with id icon.$("a").attr("target", "_blank");
// It set the target attributes for all links to load in new windows $("a").attr("target", function(){
if(this.host==location.host) return "_self"
else return "_blank";
});$("a").removeAttr("target");$("h1").css("font-weight");
// It gets font weight of first <h1>$("h1").css("font-variant", "smallcaps");
// It sets font-variant property of <h1> to smallcaps.$("h1").css({backgroundColor:"black",textColor:"white",
fontVariant:"small-caps", padding: "10px 2px 4px 20px",
border:"dotted black 4px"});
// It sets multiple styles at once for <h1>$("h1").addClass("hilite");
// It adds a class to all <h1> elements$("h1+p").addClass("hilite first");
// It adds two classes to elements after <h1>
$("section").addClass(function(n){return "scetion"+n;});
// It passes a function to add a custom class to each matched element$("p").removeClass("hilite");
// It removes a class from all p elements$("p").removeClass("hilite first");
// It removes two classes from <p> elements$("section").removeClass(function(n){return "scetion"+n;});
// It passes a function to remove a custom class to each matched element$("tr:odd").toggleClass("oddrow");
// It adds the class if it is not there or remove if it is.$("h1").toggleClass("big bold");
// It toggles two classes at once. $("h1").toggleClass(function(n){
return "big bold h1-" +n; });
// It toggles a computed class or classes.$("h1").toggleClass("hilite", true);
// It works like addclass$("h1").toggleClass("hilite", false);
// It works like removeclass$("p").hasClass("first")
// It tests any p element have class first$("#lead").is("first")
// It test any element with id lead have class first$("#firstname").val()
// It gets value from the firstname text field.$("select #extras").val()
// It gets array of values from <select multiple< from element. $("input:radio[name=ship]:checked").val()
// It gets value of checked radio button.
var title=$("head title").text() //It gets document title
var headline=$("h1").html()
//It gets the html of first <h1> element$("h1").text(function(n,current){
return "$" + (n+1) + ": "+current });
// It gives section number for each headingsvar elt=$("#sprite");
var position=elt.offset();
// It gets the current position of an elememt
position.top +=100;
// It changes its Y coordinate 100px.
elt.offset(position);
$("div").data("x",1);
//It sets some data "x" to div
$("div.nodata").removeData("x");
//It removes some data "x" from div with class nodata
var x=$("#mydiv").data("x");
//It query some data from element id "mydiv"var divs=$("div");
<script src="jquery-1.11.2.min.js"></script>
var id=$("#id");
var class=$(".class");var img=$("<img />"),
{src:url,
css:{borderWidth:5},
click:handleClick
});$(function(){
// jQuery code
});
var documentHeight=documentElement.offsetHeight;
var viewportHeight=window.innerHeight;
window.scrollTo(0, documentHeight-viewportHeight);
function gobottom(){
var documentHeight=document.documentElement.offsetHeight;
var viewportHeight=window.innerHeight;
window.scrollTo(0,documentHeight-viewportHeight);
}
<input type="button" value="Go To Bottom" onclick="gobottom();">
<script>
window.onload=function(){
var bottom=document.getElementById('bottom');
bottom.onclick=function(){
var documentHeight=document.documentElement.offsetHeight;
var viewportHeight=window.innerHeight;
window.scrollTo(0,documentHeight-viewportHeight);}
</script>
<input type="button" value="Go To Bottom" id="bottom">
window.scroll(0,0);
<script>
window.onload=function(){
var top=document.getElementById('top');
top.onclick=function(){window.scrollTo(0,0);}
</script>
<input type="button" value="Go To Top" id="top">
javascript:void setInterval(function(){scrollBy(0,10)}, 200);
window.onload=function(){
function getSelectedText(){
if (window.getSelection)
return window.getSelection().toString()+"
"+document.URL;
else if (document.selection)
return document.selection.createRange().text+"
"+document.URL;
}
var toc=document.getElementById("TOC");
if(!toc) {
toc=document.createElement("div");
toc.id="TOC";
document.body.insertBefore(toc, document.body.firstChild);
}
var headings;
if (document.querySelectorAll)
headings=document.querySelectorAll("h1, h2, h3, h4, h5, h6");
else
headings=findHeadings(document.body, []);
<style>
#TOC {border:solid black 1px; margin:10px; padding:10px;}
.TOCEntry{font-family:sans-serief;}
.TOCEntry a{text-decoration:none;}
.TOCLevel1{font-size:17pt; font-weight:bold;}
.TOCLevel2{font-size:16pt; font-weight:bold;}
.TOCLevel3{font-size:15pt; font-weight:bold;}
.TOCLevel4{font-size:14pt; margin-left:.25in;}
.TOCSectNum{display:none;}
</style>
<script>
window.onload=function(){
function getSelectedText(){
if (window.getSelection)
return window.getSelection().toString()+"<br/>"+document.URL;
else if (document.selection)
return document.selection.createRange().text+"<br/>"+document.URL;
}
var toc=document.getElementById("TOC");
if(!toc) {
toc=document.createElement("div");
toc.id="TOC";
document.body.insertBefore(toc, document.body.firstChild);
}
var headings;
if (document.querySelectorAll)
headings=document.querySelectorAll("h1, h2, h3, h4, h5, h6");
else
headings=findHeadings(document.body, []);
function findHeadings(root, sects){
for(var c=root.firstChild; c!=null; c=c.nextSibling){
if (c.nodeType!==1) continue;
if (c.tagName.length==2 && c.tagName.charAt(0)=="H")
sects.push(c);
else
findHeadings(c, sects);
}
return sects;
}
var sectionNumbers=[0,0,0,0,0,0];
for(var h=0; h<headings.length; h++) {
var heading=headings[h];
if(heading.parentNode==toc) continue;
var level=parseInt(heading.tagName.charAt(1));
if (isNaN(level)||level<1||level>6) continue;
sectionNumbers[level-1]++;
for(var i=level; i<6; i++) sectionNumbers[i]=0;
var sectionNumber=sectionNumbers.slice(0, level).join(".");
var span=document.createElement("span");
span.className="TOCSectNum";
span.innerHTML=sectionNumber;
heading.insertBefore(span, heading.firstChild);
heading.id="TOC"+sectionNumber;
var anchor=document.createElement("a");
heading.parentNode.insertBefore(anchor, heading);
anchor.appendChild(heading);
var link=document.createElement("a");
link.href="#TOC"+sectionNumber;
link.innerHTML=heading.innerHTML;
var entry=document.createElement("div");
entry.className="TOCEntry TOCLevel" + level;
entry.appendChild(link);
toc.appendChild(entry);
}
};
</script>
var elt=document.getElementById('elt');
var addresses=document.getElementsByName("address");
var addresses=document.addresses;
var para=document.getElementsByTagName("p");
var firstpara=document.getElementsByTagName("p")[0];
var firstpara=document.getElementsByTagName("p")[0];
var firstparaspans=firstpara.getElementsByTagName("span");
var colors=document.getElementByClassName("color");
var colors=document.getElementByClassName("color design");
var nav=document.querySelectorAll("#nav");
var eng=document.querySelectorAll("p[lang="en"]");
Syntax: window.open("windowname.html", "New Window", "width=width in pixel, height=height in pixel, status=yes or no, resizable=yes or no");
window.open("new_window.html", "New Window", "width=400,
height=350, status=yes, resizable=yes");
<input type=button name="open" value="Open window"
onclick="window.open('http://www.siteforinfotech.com/p/about-us.html
','new window', 'width=400, height=350, status=yes, resizable=yes');">
<a href="javascript:void window.open
('http://www.siteforinfotech.com/p/about-us.html', 'new window',
'width=400, height=350, status=yes, resizable=yes');
">Open Pop Up window</a>
var w=window.open();
w.alert("You are going to visit:http://www.siteforinfotech.com");
w.location="http://www.siteforinfotech.com";