Участник:MailGik/hilarious.js — различия между версиями
Материал из Hilarious Wiki
MailGik (обсуждение | вклад) |
MailGik (обсуждение | вклад) |
||
Строка 1: | Строка 1: | ||
/* Добавляет кнопку "Вверх" слева */ | /* Добавляет кнопку "Вверх" слева */ | ||
− | + | var snowId = document.getElementById("footer"); | |
− | document. | + | var solfId = document.createElement("a"); |
− | + | solfId.setAttribute("id","gotop"); | |
− | + | solfId.setAttribute("title","Back to top"); | |
− | + | snowId.appendChild(solfId); | |
− | + | ||
− | + | function goTop(){ | |
− | + | $(window).scroll(function(e) { | |
− | + | //If the scroll bar at the top of more than 200 elements | |
− | + | if($(window).scrollTop()>200) | |
− | + | $("#gotop").fadeIn(100);//In a second interval in the id=gotop element | |
− | + | else | |
− | + | $("#gotop").fadeOut(100);//In a second interval fade out the elements of id=gotop | |
− | + | }); | |
− | + | }; | |
− | + | $(function(){ | |
− | + | //Click back on top of the elements | |
− | + | $("#gotop").click(function(e) { | |
− | + | //Return to top with second interval | |
− | + | $('body,html').animate({scrollTop:0},100); | |
− | + | }); | |
− | + | $("#gotop").mouseover(function(e) { | |
− | + | $(this).css("background","url(http://localhost/images/backtop.gif) no-repeat 0px -100px"); | |
− | + | }); | |
− | + | $("#gotop").mouseout(function(e) { | |
− | + | $(this).css("background","url(http://localhost/images/backtop.gif) no-repeat 0px 0px"); | |
− | + | }); | |
− | + | goTop();//The fade in and fade out back to the top element | |
− | + | }); | |
− | |||
− |
Версия 17:19, 19 августа 2016
/* Добавляет кнопку "Вверх" слева */
var snowId = document.getElementById("footer");
var solfId = document.createElement("a");
solfId.setAttribute("id","gotop");
solfId.setAttribute("title","Back to top");
snowId.appendChild(solfId);
function goTop(){
$(window).scroll(function(e) {
//If the scroll bar at the top of more than 200 elements
if($(window).scrollTop()>200)
$("#gotop").fadeIn(100);//In a second interval in the id=gotop element
else
$("#gotop").fadeOut(100);//In a second interval fade out the elements of id=gotop
});
};
$(function(){
//Click back on top of the elements
$("#gotop").click(function(e) {
//Return to top with second interval
$('body,html').animate({scrollTop:0},100);
});
$("#gotop").mouseover(function(e) {
$(this).css("background","url(http://localhost/images/backtop.gif) no-repeat 0px -100px");
});
$("#gotop").mouseout(function(e) {
$(this).css("background","url(http://localhost/images/backtop.gif) no-repeat 0px 0px");
});
goTop();//The fade in and fade out back to the top element
});