Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8008013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:00:38+00:00 2026-06-04T18:00:38+00:00

HTML: <div class=promo_tumbs col_12> <div data-dir=prev class=prev></div> <div data-dir=next class=next></div> <div class=promo_tumbs_centar> <a href=#first><div

  • 0

HTML:

<div class="promo_tumbs col_12">
    <div data-dir="prev" class="prev"></div>
    <div data-dir="next" class="next"></div>
    <div class="promo_tumbs_centar">
        <a href="#first"><div class="promo_tumb promo_tumb_current">Test</div></a>
        <a href="#second"><div class="promo_tumb">Test</div></a>
        <a href="#thrid"><div class="promo_tumb">Test</div></a>
        <a href="#fourh"><div class="promo_tumb">Test</div></a>
        <a href="#fifth"><div class="promo_tumb">Test</div></a>
        <a href="#fifth"><div class="promo_tumb">Test</div></a>
        <a href="#fifth"><div class="promo_tumb">Test</div></a>
    </div>
</div>

JavaScript:

function Slider(container, nav) {
    this.container = container;
    this.nav = nav;

    this.li = this.container.find('li');
    this.li_width = this.li.first().width();
    this.li_len = this.li.length;

    this.thumbs = this.nav.find('a');

    this.current = 0;
}

Slider.prototype.transition = function(coords) {
    this.container.stop().animate({
        'margin-left': coords || -(this.current * this.li_width)
    })
}

Slider.prototype.set_current = function(dir) {
    var pos = this.current;
    if (dir === 'next') {
        pos++
    }
    else if (dir === 'prev') {
        pos--
    }
    this.current = (pos < 0) ? this.li_len - 1 : pos % this.li_len;

    return pos;
}

var slider = new Slider($('div.promo_inner ul'), $('div.promo_tumbs'));
slider.nav.find('div').on('click', function() {
    if ($(this).attr("data-dir") === undefined) {
        var index = slider.thumbs.index($(this).parent('a'));

        console.log(index)
    } else {
        slider.set_current($(this).data('dir'));
    }
    slider.transition();
})​
​

Fiddle link

When I click on element I am getting two values – index of clicked element and -1. What is going on here? How can I loose -1 and get only index value?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:00:40+00:00Added an answer on June 4, 2026 at 6:00 pm

    Call event.stopPropagation(); in order to stop the propagation of event Demo on JsFiddle

    This will give you more idea what elements causing double event Reason for multiple events JsFiddle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I've got something like the following HTML: <div class="container"> <img src="first.png" /> <img
Suppose I have the following html: This a test of <code>some code</code>. <div class='highlight'>
The HTML: <div id=timerList> ... <li rel=project class=open> <a class= style= href=><ins>&nbsp;</ins>Project C</a> </li>
I have the following html code: <div class= modal id=indexModal> <span class=thing></span> <a href=#
HTML: <div id=div_id><div class=div_class><p>test</p> </div> <div class=two> <p>asd</p></div> </div> CSS: #div_id p { color:red;
I have this html: <div class=speaker-list> <div class=view-content> <div class=views-row views-row-1 views-row-odd views-row-first> <div
<div class = a> <div class = a b> text </div> </div> <script> alert($(.a).html());
Is this html <div class='title centered'>SCE</div> <div class='description'> Magna tristique pulvinar porta montes, scelerisque
I have this HTML code: <div class='com_box'> <div class='com_box_c'> <div class='com_box_info'> <a id='quote'>quote</a> </div>
Given the following html: <div id='foo'> <div class='prodbar'> <div class='title'>Group 1</div> <div class='product'>Product #1</div>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.