Learn to implement a horizontal scroll menu in jQuery

0
5426
Implement a horizontal scroll menu in jquery

Implement a horizontal scroll menu in jquery

In our last jQuery session we learnt about how to create a form validator in jQuery. In this tutorial, we will learn to make a horizontal scrollable menu bar. This will be done in 2 steps, First of all we have to design a HTML and CSS background and then we will implement jQuery in it.
So let’s begin coding

HTML Markup

In the above example, we made three main elements. Two buttons Left and right & many button for navigation.

CSS styling

Some mix of jQuery

In jQuery, we have done lot of things. We have created below three variables and given those values.

Place variable is the variable which has the very first value.
Cur_place variable has the total of our navigation element or buttons.
winWidth has a function to get the width of browser window.

It has a resize function which is show below which works when anyone resizes the browser window.

It changes the value of elements and adjusts some major elements according to the browser window’s updated size.

This function which is shown above works when you click on the left click. If the var place value is 0, it updates the value of place variable into cur_place. But decrease the value if var place has any other value. The value of var place updates and increases by clicking to the right button. This change has made on the base element.

And the above part of script works in the exact opposite way as the left click’s script works. If you click on right button the if var place has the same value as var cur_place has, it updates the value to 0. Weather it increases the value. The change has made on the base element.

Thus we have finished this session of implementing a horizontal scroll menu in jQuery. Feel free to comment about this part of session below.

LEAVE A REPLY

Please enter your comment!
Please enter your name here