Home Get Index of Span if based on the class available
Reply: 0

Get Index of Span if based on the class available

user999
1#
user999 Published in April 24, 2018, 8:31 am

My HTML is as below.

 <div class="col-md-12 line">

   <span class="d1  available " seatid="515" seatname="A1"></span>

   <span class="d1  available " seatid="516" seatname="A2"></span>

   <span class="d1  available " seatid="555" seatname="A3"></span>

   <span class="d1  available " seatid="556" seatname="A4"></span>

   <span></span>

   <span class="d1  available " seatid="517" seatname="A5"></span>

   <span class="d1  available " seatid="518" seatname="A6"></span>

 </div>

When I click on the span I want to get the index of span comparing to all other spans having same class ,

Which means..

  1. Click on before last span I need the index as 4

This is the code I am using to take now.

var selector = $(this);
var selectIndex = selector.index();
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.412559 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO