Nov 10, 2019
White Arrow icon
Back to all Elements

Scroll & Focus

Scroll down and focus on an input field when a button is clicked

* This method also opens the keyboard when user is on mobile.

So, this one is easy peasy ;)

Add this code to your page before </body> tag

<script>

$('.btn').click(function () {

   $('html').animate({scrollTop: $('#email').offset().top - 200}, 1000);

   $('#email').focus();

});

</script>

Copy

Then give your button a 'btn' ID, and to the input field 'email' ID.

THAT's IT !

really!

Preview:

browser mockup
Share:
Heart icon

Whenever possible, use Class Names to target the elements in your interaction. You never know when you'll need to duplicate and use it somewhere else...

Might also interest you:

3d Video Slider (swiper.js)

Cloneable
CMS
JavaScript

A 3d slider with video items, plays and pauses on click & slide change.

Read more
Blue arrow iconWhite Arrow icon

Webflow Dashboard Workspaces Hack

Webflow UI Hack
Code
CSS

Convert the Workspaces dropdown to an open sidebar with custom order.

Read more
Blue arrow iconWhite Arrow icon

Glossary

Cloneable
JavaScript
CMS

A clonable for creating an Alphabetical glossary

Read more
Blue arrow iconWhite Arrow icon