0%

Hey! Do you have any query related to front end?

Sign in Sign up

Get index of an elementBack

1. What is index()

This is a function which displays the position of an element on page.

Script:

After ready your document you will have to run a click function.

$("li").click(function(){
        var li_location = $(this).index();
        $("#result span").html(li_location)
    });

"var li_lication" will hold the position value of li and "$("#result span")" will show the position output.

This will be much helpful in creating tabs and sliders.

How to comment:

  • Create an account in discuss by clicking on login next to arrow.
  • Create password for discuss and varify your email id, through your mail.
  • Refresh page and comment.

You might also like

  • Hanging menu on window scroll

    After scrolling window beyond menu height, a floating bar appears at the top having same menu inside it.

    • 279
    • 12
    • 279
    • facebook icon
    • twitter icon
    • google plus
  • Auto responsive dropdown menu

    Auto responsive dropdown menu plugin

    • 447
    • 45
    • 447
    • facebook icon
    • twitter icon
    • google plus
  • Image selection like checkbox

    Select your image like a checkbox with little jQuery

    • 338
    • 32
    • 338
    • facebook icon
    • twitter icon
    • google plus

Latest quries posted

gopa kumarabout 3 years ago

amit singhabout 3 years ago

rahmat aliabout 3 years ago

mandavi tiwariabout 3 years ago

rahul sharmaabout 3 years ago

Ask question
Latest video
Learn Angular
Profile pic
Guest Back
Username
Password