Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

scroll up

 
    // 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

scroll up

Selenium does not have a method for scrolling
but there are some ways to scroll:
#1 ->=moveToElement= coming from Actions class
   will scroll down and up to given web element
#2 Using JSExecutor: We can inject JavaScript
   code in our Java+Selenium code using JSExecutor
   which helps us scroll up, down, left, right.
   We need to create instance of JS executor,
   then cast our driver type of it.
WebDriver driver = new ChromeDriver(); 
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("scroll(0, 250);"); Scroll Down
jse.executeScript("scroll(0,-250);"); Scroll Up
Comment

PREVIOUS NEXT
Code Example
Javascript :: onclick increase counter javascript 
Javascript :: wheel 
Javascript :: how to find element in array angularjs 
Javascript :: discord.js buttons 
Javascript :: javascript add query string to url 
Javascript :: threejs perspectivecamera 
Javascript :: Iterate Through the Keys of an Object 
Javascript :: angular date pipi locale 
Javascript :: pass data ino pug nodejs 
Javascript :: address format 
Javascript :: tofixed javascript 
Javascript :: how to add an event listener to a function javascript 
Javascript :: js phone number validation 
Javascript :: electron js hide on tray icon 
Javascript :: 10 javascript interview questions 
Javascript :: trim string and place ... javascript 
Javascript :: how to export default class in javascript 
Javascript :: URLSearchParams for query params 
Javascript :: react if event.target is input 
Javascript :: angular ngstyle variable 
Javascript :: @input in angular 
Javascript :: set up emet for jsx in vs code 
Javascript :: round innerhtml value down javascript 
Javascript :: how to use text onclick to display images in javascript 
Javascript :: js alertify.success parameters 
Javascript :: ajaxsetup beforesend 
Javascript :: js convert a string into a number 
Javascript :: nodejs add to array 
Javascript :: videojs videoJsResolutionSwitcher youtube 
Javascript :: check if an element is displayed jquery 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =