所以,我试图制作一个jQuery决策树,但我不知道如何编写脚本,以便当我选择第二个问题时,它会转到另一个没有那么多if语句的树。
这是代码:
http://jsfiddle.net/iceman2hot4u/VGQ7n/1/
我无法理解为什么
if($("#tbl1_1_1").is("visible")) { jQuery("#tbl1_1_1").hide(); jQuery("#tbl1_1_1_a").show(); }不管用。 我的意思是为什么ID为“tbl1_1_1”的表格未隐藏且“tbl1_1_1_a”未显示。
So, I'am trying to make a jQuery decision tree but I don't know how to make the script so that when I select the second question it goes to another tree without so many if statements.
Here is the code:
http://jsfiddle.net/iceman2hot4u/VGQ7n/1/
And I can't understand why
if($("#tbl1_1_1").is("visible")) { jQuery("#tbl1_1_1").hide(); jQuery("#tbl1_1_1_a").show(); }is not working. I mean why the table with the id "tbl1_1_1" is not hiding and the "tbl1_1_1_a" is not showing.
最满意答案
你正在做同样的循环结束,没有任何改变试试这个:
jQuery("#tbl1_1").hide(); jQuery("#tbl1_1_1").hide(); jQuery("#tbl1_1_1_a").hide(); jQuery("#tbl2_1").hide(); jQuery(this).click(function() { if($("#tbl1_1_1").is(":visible")) { jQuery("#tbl1_1_1").hide(); jQuery("#tbl1_1_1_a").show(); } if($("#tbl1_1").is(":visible")) { jQuery("#tbl1_1").hide(); jQuery("#tbl1_1_1").show(); } if($("#tbl1").is(":visible")) { jQuery("#tbl1").hide(); jQuery("#tbl1_1").show(); } console.log("Ajunge aici."); });这条线现在处于一个条件下,并不总是执行。
jQuery("#tbl1").hide(); jQuery("#tbl1_1").show();没有这个条件,这些句子就会在每次点击时执行,然后你进入一个无限循环。
You are doing the same loop over an over, nothing change try this:
jQuery("#tbl1_1").hide(); jQuery("#tbl1_1_1").hide(); jQuery("#tbl1_1_1_a").hide(); jQuery("#tbl2_1").hide(); jQuery(this).click(function() { if($("#tbl1_1_1").is(":visible")) { jQuery("#tbl1_1_1").hide(); jQuery("#tbl1_1_1_a").show(); } if($("#tbl1_1").is(":visible")) { jQuery("#tbl1_1").hide(); jQuery("#tbl1_1_1").show(); } if($("#tbl1").is(":visible")) { jQuery("#tbl1").hide(); jQuery("#tbl1_1").show(); } console.log("Ajunge aici."); });This lines are now under a condition and not execute always.
jQuery("#tbl1").hide(); jQuery("#tbl1_1").show();Without the condition, these sentences were getting executed on every click, and you enter on an infinite loop.
决策树jQuery(Decision Tree jQuery)所以,我试图制作一个jQuery决策树,但我不知道如何编写脚本,以便当我选择第二个问题时,它会转到另一个没有那么多if语句的树。
这是代码:
http://jsfiddle.net/iceman2hot4u/VGQ7n/1/
我无法理解为什么
if($("#tbl1_1_1").is("visible")) { jQuery("#tbl1_1_1").hide(); jQuery("#tbl1_1_1_a").show(); }不管用。 我的意思是为什么ID为“tbl1_1_1”的表格未隐藏且“tbl1_1_1_a”未显示。
So, I'am trying to make a jQuery decision tree but I don't know how to make the script so that when I select the second question it goes to another tree without so many if statements.
Here is the code:
http://jsfiddle.net/iceman2hot4u/VGQ7n/1/
And I can't understand why
if($("#tbl1_1_1").is("visible")) { jQuery("#tbl1_1_1").hide(); jQuery("#tbl1_1_1_a").show(); }is not working. I mean why the table with the id "tbl1_1_1" is not hiding and the "tbl1_1_1_a" is not showing.
最满意答案
你正在做同样的循环结束,没有任何改变试试这个:
jQuery("#tbl1_1").hide(); jQuery("#tbl1_1_1").hide(); jQuery("#tbl1_1_1_a").hide(); jQuery("#tbl2_1").hide(); jQuery(this).click(function() { if($("#tbl1_1_1").is(":visible")) { jQuery("#tbl1_1_1").hide(); jQuery("#tbl1_1_1_a").show(); } if($("#tbl1_1").is(":visible")) { jQuery("#tbl1_1").hide(); jQuery("#tbl1_1_1").show(); } if($("#tbl1").is(":visible")) { jQuery("#tbl1").hide(); jQuery("#tbl1_1").show(); } console.log("Ajunge aici."); });这条线现在处于一个条件下,并不总是执行。
jQuery("#tbl1").hide(); jQuery("#tbl1_1").show();没有这个条件,这些句子就会在每次点击时执行,然后你进入一个无限循环。
You are doing the same loop over an over, nothing change try this:
jQuery("#tbl1_1").hide(); jQuery("#tbl1_1_1").hide(); jQuery("#tbl1_1_1_a").hide(); jQuery("#tbl2_1").hide(); jQuery(this).click(function() { if($("#tbl1_1_1").is(":visible")) { jQuery("#tbl1_1_1").hide(); jQuery("#tbl1_1_1_a").show(); } if($("#tbl1_1").is(":visible")) { jQuery("#tbl1_1").hide(); jQuery("#tbl1_1_1").show(); } if($("#tbl1").is(":visible")) { jQuery("#tbl1").hide(); jQuery("#tbl1_1").show(); } console.log("Ajunge aici."); });This lines are now under a condition and not execute always.
jQuery("#tbl1").hide(); jQuery("#tbl1_1").show();Without the condition, these sentences were getting executed on every click, and you enter on an infinite loop.
发布评论