Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

scroll up 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 :: How to Return Specific Values from a Filter in Javascript 
Javascript :: represent body in javascript 
Javascript :: simple user agent parse js 
Javascript :: react.lazy 
Javascript :: convert json / array to excel in javascript 
Javascript :: repeat js 
Javascript :: Accessing user input through js 
Javascript :: js get last n elements of array 
Javascript :: d3 v6 
Javascript :: javascript copy object 
Javascript :: currency format 
Javascript :: javascript regex match sequence 
Javascript :: javascript bool 
Javascript :: switch window 
Javascript :: javascript dynamic variable name 
Javascript :: redirect to dashboard after login in vue 
Javascript :: react native build 
Javascript :: js 1 minute sleep 
Javascript :: pass text and variable in alert javascript 
Javascript :: nodejs send download file from buffer 
Javascript :: flatlist inside flatlist react native 
Javascript :: js get children last 
Javascript :: math floor html 
Javascript :: installing babel from command line 
Javascript :: dropdowndirection 
Javascript :: timeout 30000 milliseconds 
Javascript :: file upload nest 
Javascript :: change cover photo with javascript 
Javascript :: Get the language of a user 
Javascript :: while loop vs for loop javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =