2010-03-13 26 views
1

我得到语法错误的萤火这里是代码:什么错与这个jQuery

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

      }); 

我想创建一个的toogle功能,被点击按钮,然后用文本区域类moderator-tex应该出现..和如果其他按钮被点击然后应该隐藏..

回答

0

试试这个:

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

如果即时未创建您的textarea,你甚至可以尝试:

$('#moderator-attention').click(function(){     
    $(".moderator-tex").slideToggle(); 
}); 
+0

我的意思做的是我有多个单选按钮时检查textarea显示..如果你选择任何其他它隐藏 –

0
$('#moderator-attention').live('toogle', function() { 
    $('.moderator-text').toggle(); 
}); 

将是我会怎么做。

不太清楚你想达到这样做你的方式是什么?

2

这里的解决方案:http://api.jquery.com/live/#multiple-events

和语法错误的发生是因为你有这样的事情:

function() { 
    function() { 

    }, 
    function() { 

    } 
} 

而这是没有意义的。

+0

我的意思是做的是我有多个单选按钮,当一个选中textarea显示..如果你选择任何其他它隐藏 –

1

根据您的问题/评论也许你应该试试这个:

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

    }); 

你应该为这个特殊的单选按钮设置一定的价值,使这项工作