简体   繁体   中英

whats wrong with this jquery

I'm getting syntax error in firebug here is the code :

$('#moderator-attention').live('toogle', function(){                  
             function () {
                $(".moderator-tex").show();
              },
              function () {
                $(".moderator-tex").hide();
              }

             });

I want to create a toogle function, when button is clicked then textarea with class moderator-tex should appear .. and if other button is clicked then should be hidden ..

Here's the solution: http://api.jquery.com/live/#multiple-events

And the syntax error occurs because you have something like this:

function() {
    function() {

    },
    function() {

    }
}

And this makes no sense.

Based on your question/comments maybe you ought to try this :

    $("input:radio").click(function() {
        var value = $this("attr", "value");
        if(value == "expected value"){
        $(".moderator-tex").show();
       }else{
       $(".moderator-tex").hide();
       }

    });

You should set some value for this particular radio button to make this work

Try this:

$('#moderator-attention').live('toogle', function(){                  
    $(".moderator-tex").slideToggle();
   }
});

If your textarea is not created on-the-fly, you can even try:

$('#moderator-attention').click(function(){                  
    $(".moderator-tex").slideToggle();
});
$('#moderator-attention').live('toogle', function () {
  $('.moderator-text').toggle();
});

Would be how I would do it.

Not quite sure what you're trying to achieve doing it your way...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM