未捕获的TypeError:无法读取null的属性“parent”

时间:2017-12-29 10:59:19

标签: javascript jquery html

你好我正在研究一个项目,如果你点击一个结果出来的结果,但当我按下按钮我看起来这个错误

error massage

错误在第9行,但不幸的是我无法弄明白,我也说jquery.js中有错误但是它在外部留下了

var current_fs, next_fs, previous_fs;
var left, opacity, scale;
var animating;
$(".next").click(function(){
    if(animating) return false;
    animating = true;

    current_fs = $(this).parent();
    next_fs = $(this).parent().next();

    $("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");

    next_fs.show(); 
    current_fs.animate({opacity: 0}, {
        step: function(now, mx) {
            scale = 1 - (1 - now) * 0.2;
            left = (now * 50)+"%";
            opacity = 1 - now;
            current_fs.css({
        'transform': 'scale('+scale+')',
        'position': 'absolute'
      });
            next_fs.css({'left': left, 'opacity': opacity});
        }, 
        duration: 800, 
        complete: function(){
            current_fs.hide();
            animating = false;
        }, 
        easing: 'easeInOutBack'
    });
});

$(".previous").click(function(){
    if(animating) return false;
    animating = true;

    current_fs = $(this).parent();
    previous_fs = $(this).parent().prev();
    $("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");
    previous_fs.show(); 
    current_fs.animate({opacity: 0}, {
        step: function(now, mx) {
            scale = 0.8 + (1 - now) * 0.2;
            left = ((1-now) * 50)+"%";
            opacity = 1 - now;
            current_fs.css({'left': left});
            previous_fs.css({'transform': 'scale('+scale+')', 'opacity': opacity});
        }, 
        duration: 800, 
        complete: function(){
            current_fs.hide();
            animating = false;
        }, 
        easing: 'easeInOutBack'
    });
});

$(".submit").click(function(){
    return false;
})



var $ = function (id) {
    return document.getElementById(id);
};

var man = $("man");
var vrouw = $("vrouw");
var kind = $("kind");
var volwassen = $("volwassen");
var vijfzestig = $("vijfzestig");
var acne = $("acne");
var grove = $("grove");
var drogehuid = $("drogehuid");
var beste = $("beste");
var make = $("make");
var jaer = $("jaer");
var neeer = $("neeer");
var hoofd = $("hoofd");
var romp = $("romp");
var benen = $("benen");

var mixColours = function mixColours() {

    if (man.checked && kind.checked && acne.checked && jaer.checked && hoofd.checked ) {
        $("colourResult").innerHTML = "ttttt";
    } else if (man.checked && volwassen.checked && acne.checked && jaer.checked && hoofd.checked) {
        $("colourResult").innerHTML = "rood wit zc";
    } else if (man.checked && vijfzestig.checked && acne.checked && jaer.checked && hoofd.checked) {
        $("colourResult").innerHTML = "rood paars zv";
    }

    if (vrouw.checked && kind.checked) {
        $("colourResult").innerHTML = "You made Yellow!";
    } else if (vrouw.checked && volwassen.checked) {
        $("colourResult").innerHTML = "You made Light Yellow!";
    }

};
window.onload = function () {
    $("mixColours").onclick = mixColours;
};

有一个部分,按钮改变了字段集,有一个动画,另一个计算最适合你的东西

如果对代码究竟是什么有任何疑问,那么我想听听

提前谢谢

0 个答案:

没有答案