Twitter bootstrap tabs and javascript events

后端 未结 7 1601
悲哀的现实
悲哀的现实 2021-01-30 05:15

I am using twitter bootstrap for a project - in particular its tab functions (http://twitter.github.com/bootstrap/javascript.html#tabs)

Now I have this tablist and when

7条回答
  •  误落风尘
    2021-01-30 05:40

    You have an error in your syntax relating to the selector:

    $('#.tabs') // should be ...
    $('.tabs');
    

    The unordered list has the class called 'tabs' in your HTML, whereas you were originally trying to select an element with the id '.tabs'.

    And you'll have to take manticore's suggestion into account too. You can only use 'change' on form elements.

    $(document).ready(function() {
        $('.tabs').click(function(e) {
            e.preventDefault();
            alert('tab clicked!');
        });
    });
    

提交回复
热议问题