[英]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 .. 我想创建一个toogle函数,当单击按钮时,应显示具有类
moderator-tex
textarea。如果单击其他按钮,则应隐藏..
Here's the solution: http://api.jquery.com/live/#multiple-events 解决方法如下: 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... 不太确定您要按照自己的方式实现的目标...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.