DEVHIDE
        • Home (current)
        • About
        • Contact
        • Cookie
        • Home (current)
        • About
        • Contact
        • Cookie
        • Disclaimer
        • Privacy
        • TOS
        Login Or Sign up

        Not able to find out the id of the button for which a jquery function was called?

        730 Views Asked by user3638694 At 17 June 2014 at 00:17 2025-12-22T08:00:42.881000

        I have two buttons in my Twitter Bootstrap wizard :-

        <div class="form-actions">
            <div class="row">
                <div class="col-sm-12">
                    <ul class="pager wizard no-margin">
                        <!--<li class="previous first disabled">
                        <a href="javascript:void(0);" class="btn btn-lg btn-default"> First </a>
                        </li>-->
                        <li class="previous disabled">
                                <a id="prev" href="javascript:void(0);" class="btn btn-lg btn-default"> Previous </a>
                        </li>
                        <!--<li class="next last">
                        <a href="javascript:void(0);" class="btn btn-lg btn-primary"> Last </a>
                        </li>-->
                        <li class="next" id="skip">
                                <a id="skip" href="javascript:void(0);" class="btn btn-lg txt-color-darken"> Skip </a>
                        </li>
                        <li class="next" id="next">
                                <a id="next" href="javascript:void(0);" class="btn btn-lg txt-color-darken"> Next </a>
                        </li>
                         <li class="next finish" style="display:none;"><a href="javascript:;">Finish</a></li>
                         <input type='button' class='btn button-last btn-default' style="display:none;" name='last' value='Skip GG setup' />
                    </ul>
                </div>
            </div>
        </div>
        

        So, the Bootstrap wizard has a function called onNext. Now in this function I am trying to find out which button the user clicked on to trigger this event. I tried something as shown in the code below but it doesn't really work.

        $('#bootstrap-wizard-1').bootstrapWizard({
            'tabClass': 'form-wizard',
            'onNext': function (tab, navigation, index) {
                $("li.next").click(function() {
                    var id = "";
                    id = this.id; // or alert($(this).attr('id'));
                    alert(id);
                });
            });
        });
        
        jquery twitter-bootstrap twitter-bootstrap-wizard
        Original Q&A
        2

        There are 2 best solutions below

        4
        Ricardo Nuñez Ricardo Nuñez On 17 June 2014 at 00:30 BEST ANSWER

        Your need to remove the click handler function. You can get the index of the clicked tab. Your HTML is not accurate or not complete. Check the documentation.

        Check this jsfiddle example.

        UPDATE: This way you get the ID. Jsfiddle

        $('#bootstrap-wizard-1').bootstrapWizard({
            'tabClass': 'form-wizard',
            'onNext': function (tab, navigation, index) {
                //
            }
        });
        
        $("li.next").click(function(event) {
            console.log(event.target.id);   // get the id
        });
        
        0
        isherwood isherwood On 17 June 2014 at 00:36

        I can't get to the Wizard docs right now, but I think this is what you'd need to do:

        'onNext': function (tab, navigation, index) {
            var id = $(tab).attr('id');
            alert(id);
        }
        

        If that doesn't work, you can probably use the index to get it:

        'onNext': function (tab, navigation, index) {
            var id = $('.wizard > li').eq(index).attr('id');
            alert(id);
        }
        

        Should probably put an ID on the ul to avoid ambiguity with the selector.

        Related Questions in JQUERY

        • In Datatables, start value resets to 0, when column sorting
        • Bootstrap modal not showing at the desired position on a web page when the screen size is smaller
        • window.location.href redirects but is causing problems on the webpage
        • Using JQuery Date Slider
        • Storing selected language in localStorage
        • How to stop other divs from still showing when i click a different button?
        • Check multiple values with jQuery
        • Bootstrap component does not want to render in Datatables function
        • put white spaces when entering an amount moneytype symfony
        • Trouble accessing custom header in AJAX response using jQuery in Fiware Keyrock
        • I just cant make it work, HTML, JS and Firebase error
        • Didn't declared variable still not getting any error in JavaScript
        • Move element horizontally while scrolling vertically in pure JavaScript
        • allow multi carousel in same page
        • Embedded TikTok posts / thumbnail styling issue

        Related Questions in TWITTER-BOOTSTRAP

        • General questions about creating a custom theme Moodle CMS
        • How to fix - The modal dissapear below 992px.?
        • Bootstrap horizontal gutters issue
        • How can I add a list of icons to the right of a text area
        • Why isn't my Bootstrap background color class working as expected?
        • Edit button in each row of table using same Bootstrap modal as add button
        • Change Opacity of Bootstrap Button
        • bootstrap 5 multiple tab dropdown with tab pane
        • Bootstrap v5.3 navbar drop-downs not working. Why?
        • Should i learn Bootstrap in 2024
        • How to turn on Bootstrap Intellisense in .NET 8 Blazor
        • Bootstrap 5.3 burger menu not responsive in Underscore WordPress template
        • Bootstrap 5 columns not displaying inline
        • Bootstrap scaffolding not showing good on mobile
        • How to Prevent Select2 Dropdown from Moving with Scroll inside a Bootstrap Vue Modal?

        Related Questions in TWITTER-BOOTSTRAP-WIZARD

        • Bootstrap-Wizard | class="active" added to wrong element
        • Cannot validate single tab per time
        • How to execute a function after modal open?
        • Bootstrap wizard not working inside Bootstrap modal or jquery-ui dialog
        • Bootstrap Wizard Issues
        • Twitter bootstrap wizard TypeError: container is undefined
        • Show error on specific input field in html table td using jQuery
        • Passing Data in wizard form without post back in MVC
        • Disable bootstrap tab without breaking pagination in wizard
        • Validation on BootstrapWizard
        • Bootstrap-Wizard: onPrevious not working with if index?
        • ignore option of jquery validate crashes my bootstrap wizard
        • Bootstrap Wizard next tab on image click and capture value
        • How do I place all properties of Javascript object into another object?
        • Bootstrap Wizard next event works only once

        Trending Questions

        • UIImageView Frame Doesn't Reflect Constraints
        • Is it possible to use adb commands to click on a view by finding its ID?
        • How to create a new web character symbol recognizable by html/javascript?
        • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
        • Heap Gives Page Fault
        • Connect ffmpeg to Visual Studio 2008
        • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
        • How to avoid default initialization of objects in std::vector?
        • second argument of the command line arguments in a format other than char** argv or char* argv[]
        • How to improve efficiency of algorithm which generates next lexicographic permutation?
        • Navigating to the another actvity app getting crash in android
        • How to read the particular message format in android and store in sqlite database?
        • Resetting inventory status after order is cancelled
        • Efficiently compute powers of X in SSE/AVX
        • Insert into an external database using ajax and php : POST 500 (Internal Server Error)

        Popular # Hahtags

        javascript python java c# php android html jquery c++ css ios sql mysql r reactjs node.js arrays c asp.net json

        Popular Questions

        • How do I undo the most recent local commits in Git?
        • How can I remove a specific item from an array in JavaScript?
        • How do I delete a Git branch locally and remotely?
        • Find all files containing a specific text (string) on Linux?
        • How do I revert a Git repository to a previous commit?
        • How do I create an HTML button that acts like a link?
        • How do I check out a remote Git branch?
        • How do I force "git pull" to overwrite local files?
        • How do I list all files of a directory?
        • How to check whether a string contains a substring in JavaScript?
        • How do I redirect to another webpage?
        • How can I iterate over rows in a Pandas DataFrame?
        • How do I convert a String to an int in Java?
        • Does Python have a string 'contains' substring method?
        • How do I check if a string contains a specific word?

        Copyright © 2021 Jogjafile Inc.

        • Disclaimer
        • Privacy
        • TOS
        • Homegardensmart
        • Pricesm.com
        • Aftereffectstemplates
        • Jogjafile