logo

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ
No Result
View All Result
logo
No Result
View All Result
Trang chủ jquery misc index() method

Jquery misc index() method

by Admin _ May 19, 2022
I"m trying khổng lồ get the index number of few "s. The li"s are 8 & I"m trying lớn get each li"s number.

Bạn đang xem: Jquery misc index() method

On each li click I vị this function:

var str = $("#amastorage li").index();alert(str);Which always give"s me 8.

EDIT:

This is how I get it:

$("#amastorage ul").find("a").click(function () var str = $("#amastorage li").index(); alert(str););I cant change: $("#amastorage ul").find("a").click(function () { because It"s from a plugin and it won"t work.

Thanks

How can I alert the li number I choosed?


*

You need lớn use the this object in the click function.

Xem thêm: Tải Game Prehistoric Park Hack, Tải Về Idle Prehistoric Park Theme Park Tycoon V0

http://jsfiddle.net/kuJWc/

$("li").click(function() var str = $(this).index(); alert(str););per your edit:

$("#amastorage ul").find("a").click(function () var str = $(this).parents("li").index(); alert(str););

*

You"ll want lớn loop through all the children of the ul and assign a click handler to each li lượt thích so:

$("#amastorage").children().each(function(i) $(this).click(function() var index = i; alert(index); ););Here"s an example in action: http://jsfiddle.net/qAuUe/


*

Thanks for contributing an answer lớn Stack Overflow!

Please be sure to answer the question. Provide details and share your research!

But avoid …

Asking for help, clarification, or responding to lớn other answers.Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.


Post Your Answer Discard

By clicking “Post Your Answer”, you agree lớn our terms of service, privacy policy và cookie policy


Not the answer you're looking for? Browse other questions tagged jquery indexing or ask your own question.


*

Site thiết kế / hình ảnh sản phẩm © 2022 Stack Exchange Inc; user contributions licensed under cc by-sa. Rev2022.5.18.42164


Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Share Tweet Linkedin Pinterest
Previous Post

Array slice method in jquery

Next Post

Get eq of element jquery

CÙNG CHUYÊN MỤC

jquery file upload (hayageek plugin) error case with json from php

Jquery file upload (hayageek plugin) error case with json from php

28/04/2021
search/filter table rows based on input

Search/filter table rows based on input

28/04/2021
jquery form validation before ajax submit

Jquery form validation before ajax submit

18/03/2021
jquery multiple select dropdown

Jquery multiple select dropdown

28/04/2021
smooth mousewheel wordpress plugin

Smooth mousewheel wordpress plugin

30/06/2022
how to get element by class name

How to get element by class name

21/06/2022
upload file with web service (asmx) using jquery ajax in asp

Upload file with web service (asmx) using jquery ajax in asp

20/06/2022
javascript array indexof() method

Javascript array indexof() method

13/06/2022

Newsletter

The most important automotive news and events of the day

We won't spam you. Pinky swear.

Chuyên Mục

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ

News Post

  • Xuất hình ảnh trong php

About

Chúng tôi tạo ra trang web nhằm mục đích mang lại kiến thức bổ ích cho cộng đồng, các bài viết được sưu tầm từ nhiều nguồn trên internet giúp mang lại kiến thức khách quan dành cho bạn

©2022 darkedeneurope.com - Website WordPress vì mục đích cộng đồng

Liên Hệ - Giới Thiệu - Nội Quy - Bảo Mật

No Result
View All Result
  • Trang chủ
  • Chuyên mục
    • Hỏi Đáp
    • Kiến Thức
    • Sức Khỏe
    • Tử Vi
    • Công Nghệ
  • Lưu trữ
  • Liên hệ

© 2022 darkedeneurope.com - Website WordPress vì mục đích cộng đồng.