请问这个js如何修改

qingwadaxia_1 2018-03-03 05:49:53
一个测试题的js 我想在点击答案的时候 自动跳转下一个 而不是每次都要选中答案之后 再点下一题

请问这种情况如何修改




链接测试地址:http://www.ncwseo.com/ceshiti/

会修改到js代码:

(function($) {
$.fn.jquizzy = function(settings) {
var defaults = {
questions: null,
startImg: 'start.gif',
endText: '已结束!',
shortURL: null,
sendResultsURL: null,
resultComments: {
perfect: '你是爱因斯坦么?',
excellent: '非常优秀!',
good: '很好,发挥不错!',
average: '一般般了。',
bad: '太可怜了!',
poor: '好可怕啊!',
worst: '悲痛欲绝!'
}
};
var config = $.extend(defaults, settings);
if (config.questions === null) {
$(this).html('<div class="intro-container slide-container"><h2 class="qTitle">Failed to parse questions.</h2></div>');
return;
}
var superContainer = $(this),
answers = [],
introFob = ' <div class="intro-container slide-container"><a class="nav-start" href="#">请认真完成测试题。准备好了吗?<br/><br/><span><img src="'+config.startImg+'"></span></a></div> ',
exitFob = '<div class="results-container slide-container"><div class="question-number">' + config.endText + '</div><div class="result-keeper"></div></div><div class="notice">请选择一个选项!</div><div class="progress-keeper" ><div class="progress"></div></div>',
contentFob = '',
questionsIteratorIndex,
answersIteratorIndex;
superContainer.addClass('main-quiz-holder');
for (questionsIteratorIndex = 0; questionsIteratorIndex < config.questions.length; questionsIteratorIndex++) {
contentFob += '<div class="slide-container"><div class="question-number">' + (questionsIteratorIndex + 1) + '/' + config.questions.length + '</div><div class="question">' + config.questions[questionsIteratorIndex].question + '</div><ul class="answers">';
for (answersIteratorIndex = 0; answersIteratorIndex < config.questions[questionsIteratorIndex].answers.length; answersIteratorIndex++) {
contentFob += '<li>' + config.questions[questionsIteratorIndex].answers[answersIteratorIndex] + '</li>';
}
contentFob += '</ul><div class="nav-container">';
if (questionsIteratorIndex !== 0) {
contentFob += '<div class="prev"><a class="nav-previous" href="#">< 上一题</a></div>';
}
if (questionsIteratorIndex < config.questions.length - 1) {
contentFob += '<div class="next"><a class="nav-next" href="#">下一题 ></a></div>';
} else {
contentFob += '<div class="next final"><a class="nav-show-result" href="#">完成</a></div>';
}
contentFob += '</div></div>';
answers.push(config.questions[questionsIteratorIndex].correctAnswer);
}
superContainer.html(introFob + contentFob + exitFob);
var progress = superContainer.find('.progress'),
progressKeeper = superContainer.find('.progress-keeper'),
notice = superContainer.find('.notice'),
progressWidth = progressKeeper.width(),
userAnswers = [],
questionLength = config.questions.length,
slidesList = superContainer.find('.slide-container');
function checkAnswers() {
var resultArr = [],
flag = false;
for (i = 0; i < answers.length; i++) {
if (answers[i] == userAnswers[i]) {
flag = true;
} else {
flag = false;
}
resultArr.push(flag);
}
return resultArr;
}
function roundReloaded(num, dec) {
var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
return result;
}
function judgeSkills(score) {
var returnString;
if (score === 100) return config.resultComments.perfect;
else if (score > 90) return config.resultComments.excellent;
else if (score > 70) return config.resultComments.good;
else if (score > 50) return config.resultComments.average;
else if (score > 35) return config.resultComments.bad;
else if (score > 20) return config.resultComments.poor;
else return config.resultComments.worst;
}
progressKeeper.hide();
notice.hide();
slidesList.hide().first().fadeIn(500);
superContainer.find('li').click(function() {
var thisLi = $(this);
if (thisLi.hasClass('selected')) {
thisLi.removeClass('selected');
} else {
thisLi.parents('.answers').children('li').removeClass('selected');
thisLi.addClass('selected');
}
});
superContainer.find('.nav-start').click(function() {
$(this).parents('.slide-container').fadeOut(500,
function() {
$(this).next().fadeIn(500);
progressKeeper.fadeIn(500);
});
return false;
});
superContainer.find('.next').click(function() {
if ($(this).parents('.slide-container').find('li.selected').length === 0) {
notice.fadeIn(300);
return false;
}
notice.hide();
$(this).parents('.slide-container').fadeOut(500,
function() {
$(this).next().fadeIn(500);
});
progress.animate({
width: progress.width() + Math.round(progressWidth / questionLength)
},
500);
return false;
});
superContainer.find('.prev').click(function() {
notice.hide();
$(this).parents('.slide-container').fadeOut(500,
function() {
$(this).prev().fadeIn(500);
});
progress.animate({
width: progress.width() - Math.round(progressWidth / questionLength)
},
500);
return false;
});
superContainer.find('.final').click(function() {
if ($(this).parents('.slide-container').find('li.selected').length === 0) {
notice.fadeIn(300);
return false;
}
superContainer.find('li.selected').each(function(index) {
userAnswers.push($(this).parents('.answers').children('li').index($(this).parents('.answers').find('li.selected')) + 1);
});
if (config.sendResultsURL !== null) {
var collate = [];
for (r = 0; r < userAnswers.length; r++) {
collate.push('{"questionNumber":"' + parseInt(r + 1, 10) + '", "userAnswer":"' + userAnswers[r] + '"}');
}
$.ajax({
type: 'POST',
url: config.sendResultsURL,
data: '{"answers": [' + collate.join(",") + ']}',
complete: function() {
console.log("OH HAI");
}
});
}
progressKeeper.hide();
var results = checkAnswers(),
resultSet = '',
trueCount = 0,
shareButton = '',
score,
url;
if (config.shortURL === null) {
config.shortURL = window.location
};
for (var i = 0,
toLoopTill = results.length; i < toLoopTill; i++) {
if (results[i] === true) {
trueCount++;
isCorrect = true;
}
resultSet += '<div class="result-row">' + (results[i] === true ? "<div class='correct'>#"+(i + 1)+"<span></span></div>": "<div class='wrong'>#"+(i + 1)+"<span></span></div>");
resultSet += '<div class="resultsview-qhover">' + config.questions[i].question;
resultSet += "<ul>";
for (answersIteratorIndex = 0; answersIteratorIndex < config.questions[i].answers.length; answersIteratorIndex++) {
var classestoAdd = '';
if (config.questions[i].correctAnswer == answersIteratorIndex + 1) {
classestoAdd += 'right';
}
if (userAnswers[i] == answersIteratorIndex + 1) {
classestoAdd += ' selected';
}
resultSet += '<li class="' + classestoAdd + '">' + config.questions[i].answers[answersIteratorIndex] + '</li>';
}
resultSet += '</ul></div></div>';
}
score = roundReloaded(trueCount / questionLength * 100, 2);

resultSet = '<h2 class="qTitle">' + judgeSkills(score) + '<br/> 您的分数: ' + score + '</h2>' + shareButton + '<div class="jquizzy-clear"></div>' + resultSet + '<div class="jquizzy-clear"></div>';
superContainer.find('.result-keeper').html(resultSet).show(500);
superContainer.find('.resultsview-qhover').hide();
superContainer.find('.result-row').hover(function() {
$(this).find('.resultsview-qhover').show();
},
function() {
$(this).find('.resultsview-qhover').hide();
});
$(this).parents('.slide-container').fadeOut(500,
function() {
$(this).next().fadeIn(500);
});
return false;
});
};
})(jQuery);

看着有点多 费心了
...全文
629 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
Logerlink 2018-03-05
  • 打赏
  • 举报
回复

var toNext = function (that,progress) {
if ($(that).parents('.slide-container').find('li.selected').length === 0) {
notice.fadeIn(300);
return false;
}
notice.hide();
$(that).parents('.slide-container').fadeOut(500,
function () {
$(this).next().fadeIn(500);
});
progress.animate({
width: progress.width() + Math.round(progressWidth / questionLength)
},
500);
return false;
}

将点击下一题的事件抽出来(函数toNext),在ajax验证答案后的complete(函数)中调用toNext函数

没有调式过,没有代码我也调式不了~~,大概就是这样吧
Logerlink 2018-03-05
  • 打赏
  • 举报
回复
html发一下
qingwadaxia_1 2018-03-05
  • 打赏
  • 举报
回复
有大神回答下吗。
qingwadaxia_1 2018-03-05
  • 打赏
  • 举报
回复
引用 12 楼 Logerlink 的回复:

//提交事件
                var answerSubmit = function (that) {
                    if ($(that).parents('.slide-container').find('li.selected').length === 0) {
                        notice.fadeIn(300);
                        console.log("11111");
                        return false;
                    }
                    console.log("....");
                    superContainer.find('li.selected').each(function (index) {
                        userAnswers.push($(this).parents('.answers').children('li').index($(this).parents('.answers').find('li.selected')) + 1);
                    });
                    if (config.sendResultsURL !== null) {
                        var collate = [];
                        for (r = 0; r < userAnswers.length; r++) {
                            collate.push('{"questionNumber":"' + parseInt(r + 1, 10) + '", "userAnswer":"' + userAnswers[r] + '"}');
                        }
                        
                        $.ajax({
                            type: 'POST',
                            url: config.sendResultsURL,
                            data: '{"answers": [' + collate.join(",") + ']}',
                            complete: function () {
                                console.log("OH HAI");
                                //前往下一题
                                //toNext(this, progress, notice, progressWidth, questionLength);
                            }
                        });
                    }
                    progressKeeper.hide();
                    var results = checkAnswers(),
                    resultSet = '',
                    trueCount = 0,
                    shareButton = '',
                    score,
                    url;
                    if (config.shortURL === null) {
                        config.shortURL = window.location
                    };
                    for (var i = 0,
                    toLoopTill = results.length; i < toLoopTill; i++) {
                        if (results[i] === true) {
                            trueCount++;
                            isCorrect = true;
                        }
                        resultSet += '<div class="result-row">' + (results[i] === true ? "<div class='correct'>#" + (i + 1) + "<span></span></div>" : "<div class='wrong'>#" + (i + 1) + "<span></span></div>");
                        resultSet += '<div class="resultsview-qhover">' + config.questions[i].question;
                        resultSet += "<ul>";
                        for (answersIteratorIndex = 0; answersIteratorIndex < config.questions[i].answers.length; answersIteratorIndex++) {
                            var classestoAdd = '';
                            if (config.questions[i].correctAnswer == answersIteratorIndex + 1) {
                                classestoAdd += 'right';
                            }
                            if (userAnswers[i] == answersIteratorIndex + 1) {
                                classestoAdd += ' selected';
                            }
                            resultSet += '<li class="' + classestoAdd + '">' + config.questions[i].answers[answersIteratorIndex] + '</li>';
                        }
                        resultSet += '</ul></div></div>';
                    }
                    score = roundReloaded(trueCount / questionLength * 100, 2);

                    resultSet = '<h2 class="qTitle">' + judgeSkills(score) + '<br/> 您的分数: ' + score + '</h2>' + shareButton + '<div class="jquizzy-clear"></div>' + resultSet + '<div class="jquizzy-clear"></div>';
                    superContainer.find('.result-keeper').html(resultSet).show(500);
                    superContainer.find('.resultsview-qhover').hide();
                    superContainer.find('.result-row').hover(function () {
                        $(this).find('.resultsview-qhover').show();
                    },
                    function () {
                        $(this).find('.resultsview-qhover').hide();
                    });
                    $(that).parents('.slide-container').fadeOut(500,
                    function () {
                        $(this).next().fadeIn(500);
                    });
                    return false;
                }
                
            };
        })(jQuery);
        var toNext = function (that, progress, notice, progressWidth, questionLength) {
            if ($(that).parents('.slide-container').find('li.selected').length === 0) {
                notice.fadeIn(300);
                return false;
            }
            notice.hide();
            $(that).parents('.slide-container').fadeOut(500,
            function () {
                $(this).next().fadeIn(500);
            });
            progress.animate({
                width: progress.width() + Math.round(progressWidth / questionLength)
            },
            500);
            return false;
        }
感谢! 没说的!
Logerlink 2018-03-05
  • 打赏
  • 举报
回复

//提交事件
                var answerSubmit = function (that) {
                    if ($(that).parents('.slide-container').find('li.selected').length === 0) {
                        notice.fadeIn(300);
                        console.log("11111");
                        return false;
                    }
                    console.log("....");
                    superContainer.find('li.selected').each(function (index) {
                        userAnswers.push($(this).parents('.answers').children('li').index($(this).parents('.answers').find('li.selected')) + 1);
                    });
                    if (config.sendResultsURL !== null) {
                        var collate = [];
                        for (r = 0; r < userAnswers.length; r++) {
                            collate.push('{"questionNumber":"' + parseInt(r + 1, 10) + '", "userAnswer":"' + userAnswers[r] + '"}');
                        }
                        
                        $.ajax({
                            type: 'POST',
                            url: config.sendResultsURL,
                            data: '{"answers": [' + collate.join(",") + ']}',
                            complete: function () {
                                console.log("OH HAI");
                                //前往下一题
                                //toNext(this, progress, notice, progressWidth, questionLength);
                            }
                        });
                    }
                    progressKeeper.hide();
                    var results = checkAnswers(),
                    resultSet = '',
                    trueCount = 0,
                    shareButton = '',
                    score,
                    url;
                    if (config.shortURL === null) {
                        config.shortURL = window.location
                    };
                    for (var i = 0,
                    toLoopTill = results.length; i < toLoopTill; i++) {
                        if (results[i] === true) {
                            trueCount++;
                            isCorrect = true;
                        }
                        resultSet += '<div class="result-row">' + (results[i] === true ? "<div class='correct'>#" + (i + 1) + "<span></span></div>" : "<div class='wrong'>#" + (i + 1) + "<span></span></div>");
                        resultSet += '<div class="resultsview-qhover">' + config.questions[i].question;
                        resultSet += "<ul>";
                        for (answersIteratorIndex = 0; answersIteratorIndex < config.questions[i].answers.length; answersIteratorIndex++) {
                            var classestoAdd = '';
                            if (config.questions[i].correctAnswer == answersIteratorIndex + 1) {
                                classestoAdd += 'right';
                            }
                            if (userAnswers[i] == answersIteratorIndex + 1) {
                                classestoAdd += ' selected';
                            }
                            resultSet += '<li class="' + classestoAdd + '">' + config.questions[i].answers[answersIteratorIndex] + '</li>';
                        }
                        resultSet += '</ul></div></div>';
                    }
                    score = roundReloaded(trueCount / questionLength * 100, 2);

                    resultSet = '<h2 class="qTitle">' + judgeSkills(score) + '<br/> 您的分数: ' + score + '</h2>' + shareButton + '<div class="jquizzy-clear"></div>' + resultSet + '<div class="jquizzy-clear"></div>';
                    superContainer.find('.result-keeper').html(resultSet).show(500);
                    superContainer.find('.resultsview-qhover').hide();
                    superContainer.find('.result-row').hover(function () {
                        $(this).find('.resultsview-qhover').show();
                    },
                    function () {
                        $(this).find('.resultsview-qhover').hide();
                    });
                    $(that).parents('.slide-container').fadeOut(500,
                    function () {
                        $(this).next().fadeIn(500);
                    });
                    return false;
                }
                
            };
        })(jQuery);
        var toNext = function (that, progress, notice, progressWidth, questionLength) {
            if ($(that).parents('.slide-container').find('li.selected').length === 0) {
                notice.fadeIn(300);
                return false;
            }
            notice.hide();
            $(that).parents('.slide-container').fadeOut(500,
            function () {
                $(this).next().fadeIn(500);
            });
            progress.animate({
                width: progress.width() + Math.round(progressWidth / questionLength)
            },
            500);
            return false;
        }
Logerlink 2018-03-05
  • 打赏
  • 举报
回复

(function ($) {
            $.fn.jquizzy = function (settings) {
                var defaults = {
                    questions: null,
                    startImg: 'start.gif',
                    endText: '已结束!',
                    shortURL: null,
                    sendResultsURL: null,
                    resultComments: {
                        perfect: '你是爱因斯坦么?',
                        excellent: '非常优秀!',
                        good: '很好,发挥不错!',
                        average: '一般般了。',
                        bad: '太可怜了!',
                        poor: '好可怕啊!',
                        worst: '悲痛欲绝!'
                    }
                };
                var config = $.extend(defaults, settings);
                if (config.questions === null) {
                    $(this).html('<div class="intro-container slide-container"><h2 class="qTitle">Failed to parse questions.</h2></div>');
                    return;
                }
                var superContainer = $(this),
                answers = [],
                introFob = '	<div class="intro-container slide-container"><a class="nav-start" href="#">请认真完成测试题。准备好了吗?<br/><br/><span><img src="' + config.startImg + '"></span></a></div>	',
                exitFob = '<div class="results-container slide-container"><div class="question-number">' + config.endText + '</div><div class="result-keeper"></div></div><div class="notice">请选择一个选项!</div><div class="progress-keeper" ><div class="progress"></div></div>',
                contentFob = '',
                questionsIteratorIndex,
                answersIteratorIndex;
                superContainer.addClass('main-quiz-holder');
                for (questionsIteratorIndex = 0; questionsIteratorIndex < config.questions.length; questionsIteratorIndex++) {
                    contentFob += '<div class="slide-container"><div class="question-number">' + (questionsIteratorIndex + 1) + '/' + config.questions.length + '</div><div class="question">' + config.questions[questionsIteratorIndex].question + '</div><ul class="answers">';
                    for (answersIteratorIndex = 0; answersIteratorIndex < config.questions[questionsIteratorIndex].answers.length; answersIteratorIndex++) {
                        contentFob += '<li>' + config.questions[questionsIteratorIndex].answers[answersIteratorIndex] + '</li>';
                    }
                    contentFob += '</ul><div class="nav-container">';
                    if (questionsIteratorIndex !== 0) {
                        contentFob += '<div class="prev"><a class="nav-previous" href="#">< 上一题</a></div>';
                    }
                    if (questionsIteratorIndex < config.questions.length - 1) {
                        contentFob += '<div class="next"><a class="nav-next" href="#">下一题 ></a></div>';
                    } else {
                        contentFob += '<div class="next final"><a class="nav-show-result" href="#">完成</a></div>';
                    }
                    contentFob += '</div></div>';
                    answers.push(config.questions[questionsIteratorIndex].correctAnswer);
                }
                superContainer.html(introFob + contentFob + exitFob);
                var progress = superContainer.find('.progress'),
                progressKeeper = superContainer.find('.progress-keeper'),
                notice = superContainer.find('.notice'),
                progressWidth = progressKeeper.width(),
                userAnswers = [],
                questionLength = config.questions.length,
                slidesList = superContainer.find('.slide-container');
                function checkAnswers() {
                    var resultArr = [],
                    flag = false;
                    for (i = 0; i < answers.length; i++) {
                        if (answers[i] == userAnswers[i]) {
                            flag = true;
                        } else {
                            flag = false;
                        }
                        resultArr.push(flag);
                    }
                    return resultArr;
                }
                function roundReloaded(num, dec) {
                    var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
                    return result;
                }
                function judgeSkills(score) {
                    var returnString;
                    if (score === 100) return config.resultComments.perfect;
                    else if (score > 90) return config.resultComments.excellent;
                    else if (score > 70) return config.resultComments.good;
                    else if (score > 50) return config.resultComments.average;
                    else if (score > 35) return config.resultComments.bad;
                    else if (score > 20) return config.resultComments.poor;
                    else return config.resultComments.worst;
                }
                progressKeeper.hide();
                notice.hide();
                slidesList.hide().first().fadeIn(500);
                superContainer.find('li').click(function () {
                    var thisLi = $(this);
                    if (thisLi.hasClass('selected')) {
                        thisLi.removeClass('selected');
                    } else {
                        thisLi.parents('.answers').children('li').removeClass('selected');
                        thisLi.addClass('selected');
                    }
                });
                superContainer.find('.nav-start').click(function () {
                    $(this).parents('.slide-container').fadeOut(500,
                    function () {
                        $(this).next().fadeIn(500);
                        progressKeeper.fadeIn(500);
                    });
                    return false;
                });
                superContainer.find('.prev').click(function () {
                    notice.hide();
                    $(this).parents('.slide-container').fadeOut(500,
                    function () {
                        $(this).prev().fadeIn(500);
                    });
                    progress.animate({
                        width: progress.width() - Math.round(progressWidth / questionLength)
                    },
                    500);
                    return false;
                });
                superContainer.find(".next").click(function () {
                    toNext(this, progress, notice, progressWidth, questionLength);
                });
                superContainer.find('.final').click(function () {
                    answerSubmit(this);
                });
                $('.answers li').click(function () {
                    if ($(".slide-container:eq(4)").attr("style") == "display: block;") {
                        //最后一题
                        answerSubmit(this);
                        return;
                    }
                    toNext(this, progress, notice, progressWidth, questionLength);
                });
qingwadaxia_1 2018-03-05
  • 打赏
  • 举报
回复
引用 7 楼 Logerlink 的回复:
好吧 我的 不过有了html就明了多了 在合适的地方加上这一段

$('.answers li').click(function () {
                    if ($(".slide-container:eq(4)").attr("style")=="display: block;"){
                        //最后一题
                        alert("请点击完成");
                        return;
                    }
                    toNext(this, progress, notice, progressWidth, questionLength);
                });
再将上面原来的toNext换成这个 toNext(this, progress, notice, progressWidth, questionLength);
好像已经可以实现点击题目答案 自动跳到下一题 但是请问如何在最后第一题的时候 直接跳到结果 而不是还要点击完成 ,另外大神你这代码改的我有点眼花 请问能不发一个完整版的
Logerlink 2018-03-05
  • 打赏
  • 举报
回复
你不会玩吗???
qingwadaxia_1 2018-03-05
  • 打赏
  • 举报
回复
引用 7 楼 Logerlink 的回复:
好吧 我的 不过有了html就明了多了 在合适的地方加上这一段

$('.answers li').click(function () {
                    if ($(".slide-container:eq(4)").attr("style")=="display: block;"){
                        //最后一题
                        alert("请点击完成");
                        return;
                    }
                    toNext(this, progress, notice, progressWidth, questionLength);
                });
再将上面原来的toNext换成这个 toNext(this, progress, notice, progressWidth, questionLength);
我是想选中答案的时候 可以自动下一题哎 这是弹出吗?
Logerlink 2018-03-05
  • 打赏
  • 举报
回复
好吧 我的 不过有了html就明了多了 在合适的地方加上这一段

$('.answers li').click(function () {
                    if ($(".slide-container:eq(4)").attr("style")=="display: block;"){
                        //最后一题
                        alert("请点击完成");
                        return;
                    }
                    toNext(this, progress, notice, progressWidth, questionLength);
                });
再将上面原来的toNext换成这个 toNext(this, progress, notice, progressWidth, questionLength);
qingwadaxia_1 2018-03-05
  • 打赏
  • 举报
回复
引用 4 楼 Logerlink 的回复:

var toNext = function (that,progress) {
            if ($(that).parents('.slide-container').find('li.selected').length === 0) {
                notice.fadeIn(300);
                return false;
            }
            notice.hide();
            $(that).parents('.slide-container').fadeOut(500,
            function () {
                $(this).next().fadeIn(500);
            });
            progress.animate({
                width: progress.width() + Math.round(progressWidth / questionLength)
            },
            500);
            return false;
        }
将点击下一题的事件抽出来(函数toNext),在ajax验证答案后的complete(函数)中调用toNext函数 没有调式过,没有代码我也调式不了~~,大概就是这样吧
请问该了哪里呢 好像没用啊。
qingwadaxia_1 2018-03-05
  • 打赏
  • 举报
回复
引用 4 楼 Logerlink 的回复:

var toNext = function (that,progress) {
            if ($(that).parents('.slide-container').find('li.selected').length === 0) {
                notice.fadeIn(300);
                return false;
            }
            notice.hide();
            $(that).parents('.slide-container').fadeOut(500,
            function () {
                $(this).next().fadeIn(500);
            });
            progress.animate({
                width: progress.width() + Math.round(progressWidth / questionLength)
            },
            500);
            return false;
        }
将点击下一题的事件抽出来(函数toNext),在ajax验证答案后的complete(函数)中调用toNext函数 没有调式过,没有代码我也调式不了~~,大概就是这样吧
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>炫酷在线答题测试js特效代码</title> <meta name="keywords" content="炫酷,在线答题,测试,js特效,代码" /> <meta name="description" content="炫酷在线答题测试js特效代码。" /> <meta name="author" content="js代码" /> <meta name="copyright" content="js代码" /> <link rel="stylesheet" type="text/css" href="styles.css" /> </head> <body> <div class="container" id="main"> <div class="demo"> <div id='quiz_area'></div> </div> </div> <script type="text/javascript" src="jquery.js"></script> <script src="quiz.js"></script> <script> var init = {'questions': [{'question': 'jQuery是什么?', 'answers': ['JavaScript库', 'CSS库', 'PHP框架', '以上都不是'], 'correctAnswer': 1}, {'question': '找出不同类的一项?', 'answers': ['写字台', '沙发', '电视', '桌布'], 'correctAnswer': 3}, {'question': '国土面积最大的国家是:', 'answers': ['美国', '中国', '俄罗斯', '加拿大'], 'correctAnswer': 3}, {'question': '月亮距离地球多远?', 'answers': ['18万公里', '38万公里', '100万公里', '180万公里'], 'correctAnswer': 2}]}; $(function() { $('#quiz_area').jquizzy({ questions: init.questions }); }); </script> </body> </html>
qingwadaxia_1 2018-03-03
  • 打赏
  • 举报
回复
这题估计没人回答吧。。。是不是太长了。

87,845

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧