Gandalf StormCrow
Gandalf StormCrow

Reputation: 26192

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 ..

Upvotes: 1

Views: 98

Answers (4)

ant
ant

Reputation: 22948

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

Upvotes: 1

Crozin
Crozin

Reputation: 44376

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.

Upvotes: 2

Matt
Matt

Reputation: 75307

$('#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...

Upvotes: 0

Sarfraz
Sarfraz

Reputation: 382656

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();
});

Upvotes: 0

Related Questions