我是jquery interdependencies的新手。使用单选按钮选择的正确方法是什么?在这个例子中,我试图显示问题2A,如果" A"被选中,问题2B如果" B"被选中。
HTML:
<div>
<span>Question 1</span>
<input type="radio" id="radioQ1" name="firstQuestion" value="answerA">A<br>
<input type="radio" id="radioQ2" name="firstQuestion" value="answerB">B
</div>
<div id="Q2A">
<span>Question 2A</span>
Etc. etc. etc.
</div>
<div id="Q2B">
<span>Question 2B</span>
Etc. etc. etc.
</div>
JS:
$(document).ready(function() {
// Start creating a new ruleset
var ruleset = $.deps.createRuleset();
var myRule2A= ruleset.createRule("#radioQ1", "==", "answerA"); //also tried "true" (without quotes)
myRule2A.include("#Q2A");
var myRule2B = ruleset.createRule("#radioQ2", "==", "answerB");
myRule2B.include("#Q2B");
// Make the ruleset effective on the whole page
ruleset.install({log: true});
});
答案 0 :(得分:0)
我明白了:
JS
var myRule2A = ruleset.createRule("#radioQ1", "==", true);
myRule1.include("#Q2A");
var myRule2B = ruleset.createRule("#radioQ2", "==", true);
myRule1.include("#Q2B");