Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

scroll btn

 
    // when click a btn page scroll  and go to home   
    $(window).scroll(function () {
        if ($(this).scrollTop() > 200) {
            $("#scroll-top").fadeIn(100)
        } else { $("#scroll-top").fadeOut()}
    })

    $("#scroll-top").click(function () {
        $("html,body").animate({ scrollTop: 0 }, "3000")
    })

// when click a link and go to section smoothly
// smooth scroll for all browser
	$('a').click(function (event) {
		if (this.hash !== '') {
			event.preventDefault();
			let hash = this.hash;
			$('html,body').animate({ scrollTop: $(hash).offset().top }, 800, function () {
				window.location.hash = hash;
			});
		}
	});
Comment

PREVIOUS NEXT
Code Example
Javascript :: react file preview 
Javascript :: How to Return Specific Values from a Filter in Javascript 
Javascript :: javascript /g 
Javascript :: date range npm 
Javascript :: add svg in react 
Javascript :: use of this keyword in js 
Javascript :: how to map through an object javascript 
Javascript :: bin to bit string javascript 
Javascript :: angularjs make post request 
Javascript :: address format json 
Javascript :: hoisting in javascript 
Javascript :: js element on mouse over 
Javascript :: react-native-bouncy-checkbox 
Javascript :: how to separate string elements in javascript 
Javascript :: streami node js 
Javascript :: get string length js 
Javascript :: json example list of objects 
Javascript :: get query params 
Javascript :: javascript isempty 
Javascript :: convert array to object with custom keys 
Javascript :: @output() angular 
Javascript :: uncaught exception javascript 
Javascript :: math.floor javascript 
Javascript :: convert number to hex js 
Javascript :: return array content only js 
Javascript :: add language switcher to react-admin 
Javascript :: recaptcha v3 
Javascript :: mongoose auto increment 
Javascript :: flask vue.js not working 
Javascript :: import json file into javascript 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =