开发者

whats wrong with this jquery

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

$('#moderator-attention').live('toogle', fu开发者_运维知识库nction(){                  
             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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜