Home > Web Front-end > JS Tutorial > Get the clicked tab page through the same class in jQuery

Get the clicked tab page through the same class in jQuery

巴扎黑
Release: 2017-07-20 13:30:22
Original
1450 people have browsed it

Judge which tab page is clicked

  • ##jsp:

<ul class="nav nav-tabs">
     <li class="active">
     <a href="#tab-1" class="stability-test" data-marker="tab1" data-toggle="tab" aria-expanded="true">tab1</a>
      </li>
      <li class="">
<a href="#tab-2" class="stability-test" data-marker="tab2" data-toggle="tab"aria-expanded="false">tab2</a>
    </li>
 </ul>
Copy after login
  • js:

 $('.stability-test').click(function(e) {
        var $this = $(e.target);
        marker = $this.data('marker');
    });
Copy after login
Another method is:

There is an index() event in jq to obtain the current position. The specific usage is as follows:

$(".class").click(function(){
    alert($(this).index());
})//这个弹出的就是点击的class是第几个
Copy after login


The above is the detailed content of Get the clicked tab page through the same class in jQuery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template