Code-JQuery

$(document).ready(function() {

$('#myBtn').on('click', function() {
$(document.body).animate({scrollTop: 0}, 1000);
$(document.documentElement).animate({scrollTop: 0}, 1000);
});

});


Hi Max!!!
$(document).ready(function() {

$("#slideshow > div:gt(0)").hide();

setInterval(function() {
$('#slideshow > div:first')
.fadeOut(1000)
.next()
.fadeIn(1000)
.end()
.appendTo('#slideshow');
}, 3000);

});

/* CSS Code */
#slideshow {
margin: 80px auto;
position: relative;
width: 240px;
height: 240px;
padding: 10px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
}

#slideshow > div {
position: absolute;
top: 10px;
left: 10px;
right: 10px;
bottom: 10px;
}

/* HTML Code */
<div id="slideshow">
<div>
<img src="http://farm6.static.flickr.com/5224/5658667829_2bb7d42a9c_m.jpg" />
</div>
<div>
<img src="http://farm6.static.flickr.com/5230/5638093881_a791e4f819_m.jpg" />
</div>
<div>
Pretty cool eh? This slide is proof the content can be anything.
</div>
</div>
$("#kitten").hover(function(){
$(this).find("img").fadeOut();
}, function() {
$(this).find("img").fadeIn();
});

/* USAGE */
<div id="kitten" style="background-image: url(dog.jpg);">
<img src="/images/kitten.jpg" alt="Kitten" />
</div>
(function($) {
$.fn.drags = function(opt) {

opt = $.extend({handle:"",cursor:"move"}, opt);

if(opt.handle === "") {
var $el = this;
} else {
var $el = this.find(opt.handle);
}

return $el.css('cursor', opt.cursor).on("mousedown", function(e) {
if(opt.handle === "") {
var $drag = $(this).addClass('draggable');
} else {
var $drag = $(this).addClass('active-handle').parent().addClass('draggable');
}
var z_idx = $drag.css('z-index'),
drg_h = $drag.outerHeight(),
drg_w = $drag.outerWidth(),
pos_y = $drag.offset().top + drg_h - e.pageY,
pos_x = $drag.offset().left + drg_w - e.pageX;
$drag.css('z-index', 1000).parents().on("mousemove", function(e) {
$('.draggable').offset({
top:e.pageY + pos_y - drg_h,
left:e.pageX + pos_x - drg_w
}).on("mouseup", function() {
$(this).removeClass('draggable').css('z-index', z_idx);
});
});
e.preventDefault(); // disable selection
}).on("mouseup", function() {
if(opt.handle === "") {
$(this).removeClass('draggable');
} else {
$(this).removeClass('active-handle').parent().removeClass('draggable');
}
});

}
})(jQuery);

/* USAGE */
$('div').drags();
$(document).ready(function() {

$("p").css("background-color","yellow");

$("a").click(function(event) {
alert("Thanks for visiting!");
});

/* Hover on/off element */
$("#selector").hover(function() {
$(this).css("cursor","pointer");
}, function() {
$(this).css("cursor","auto");
});

});

/* Below is a brief overview of some of the most commonly used selectors. */

$("*") - Wildcard: /* selects every element on the page. */
$(this) - Current: /* selects the current element being operated on within a function. */
$("p") - Tag: /* selects every instance of the <p> tag. */
$(".example") - Class: /* selects every element that has the example class applied to it. */
$("#example") - Id: /* selects a single instance of the unique example id. */
$("[type='text']") - Attribute: /* selects any element with text applied to the type attribute. */
$("p:first-of-type") - Pseudo Element: /* selects the first <p>. */
My code blog is a great place to store and share code snippets, just like this favourite JQuery one.

Apply this to any element to create a mouse over effect
that changes the mouse pointer to hand and back again.
$("#selector").hover(function() {
$(this).css('cursor','pointer');
}, function() {
$(this).css('cursor','auto');
});

See it in action!

Hover Me!
GnasheR's Snippets
GnasheR

PHP as it's known today is actually the successor to a product named PHP/FI. Created in 1994 by Rasmus Lerdorf, the very first incarnation of PHP was a simple set of Common Gateway Interface (CGI) binaries written in the C programming language. Originally used for tracking visits to his online resume, he named the suite of scripts "Personal Home Page Tools," more frequently referenced as "PHP Tools." Over time, more functionality was desired, and Rasmus rewrote PHP Tools, producing a much larger and richer implementation. This new model was capable of database interaction and more, providing a framework upon which users could develop simple dynamic web applications such as guestbooks. In June of 1995, Rasmus released the source code for PHP Tools to the public, which allowed developers to use it as they saw fit. This also permitted and encouraged users to provide fixes for bugs in the code, and to generally improve upon it.
Go To Top