アンケートがあり、ユーザーがオプション 1 または 2 をSelect an Option
選択すると、アンケートの最後に表示されるリンクが決まります。のオプションを 2 つだけではなく、3 つにしたいと考えていますSelect an Option
。
HTMLは次のとおりです。
<a id="q1_one" class="step_button next" href="javascript:void(0)">option 1</a>
<a id="q1_two" class="step_button next" href="javascript:void(0)">option 2</a>
これは私が追加したい場所ですが、q1_three
それを機能させる方法がわかりません
Javascript:
function run_loading_run_4(time_delay, q1) {
timeoutID3 = window.setTimeout(
function() {
run_loading_4(q1);
},
time_delay);
}
function run_loading_4(q1) {
$('.run_loading_4, .loading').hide();
$('.li_run_loading_4, li_run_loading_5, .run_loading_5, .show_end').fadeIn();
$('#' + q1).show();
}
$(function () {
var q1;
$(document).on('click', '.next', function (e) {
e.preventDefault();
$(this).parent().hide().next().fadeIn();
if ($(this).attr('id') === "q1_one") {
q1 = "yes";
} else if ($(this).attr('id') === "q1_two") {
q1 = "no";
}
});
$(document).on('click', '.run_loading', function (e) {
e.preventDefault();
$(this).parent().hide().next().fadeIn();
$('.step4 .loading').show();
run_loading_run_1('2000');
run_loading_run_2('4500');
run_loading_run_3('6500');
run_loading_run_4('8900',q1);
});
});
および回答: オプション 1 または 2 が選択されているかどうかに応じて表示されます。
<div id="yes">
<a class="step_button" href="http://link1.com">I Agree</a>
</div>
<div id="no">
<a class="step_button" href="http://link2.com">I Agree</a>
</div>
JSFIDDLE: http://jsfiddle.net/8r6eH/