Skip to main content

Bug Tracker

Side navigation

#2193 closed bug (invalid)

Opened January 19, 2008 05:08PM UTC

Closed January 19, 2008 07:54PM UTC

toggle( FunctionA reference to a Javascript function. evenThe function to execute on every even click., FunctionA reference to a Javascript function. oddThe function to execute on every odd click. )

Reported by: windark Owned by:
Priority: major Milestone: 1.2.3
Component: core Version: 1.2.2
Keywords: Cc:
Blocked by: Blocking:
Description

my code:

$(document).ready(function(){

$('#btn_tog').click(function(){

$("li").toggle(

function () {

alert('1');

},

function () {

alert('2');

});

});

});

this code can't alert the message when i click the button.my jquery version is 1.2.2.

Attachments (0)
Change History (1)

Changed January 19, 2008 07:54PM UTC by scott.gonzal comment:1

resolution: → invalid
status: newclosed

The posted code is not setup to alert on a button click. It is setup to alert when the user clicks on an li element, after clicking the button.

$(document).ready(function(){
    // this sets up a click event on the element with id "btn_tog"
    $('#btn_tog').click(function(){
        // this sets up a click event on all li elements
        $("li").toggle(
            function () {
                alert('1');
            }, function () {
                alert('2');
            });
    });
});

Your example is unclear about what your desired behavior is, but you probably wanted something more like:

$('#btn_tog').toggle(
    function() {
        alert('even');
    },
    function() {
        alert('odd');
    }
);