mercredi 17 juillet 2019

How can I make a if and else-if statement in jQuery for is clicked

What can I solve this problem with if-else? I like to do "if this and this clicked before" or "this and this clicked before" then do something. Look to the bottom of the code.

$("#sjf").click(function () {
        $("#sjftable").show();
        $("#fcfstable").hide();
    });

    $("#fcfs").click(function () {
        $("#fcfstable").show();
        $("#sjftable").hide();
    });

    $("#rr").click(function () {
        $("#sjftable").show();
        $("#fcfstable").hide();
    });

    $("#srtf").click(function () {
        $("#fcfstable").show();
        $("#sjftable").hide();
    });

$("#berechnen").click(function () {
    if ($("#fcfs, #srtf").data("clicked")) {
                for (let i = 1; i <= anzahlProzesse; i++) {
                    let cpu = $("#prozess" + i).val();
                    cpuLaufzeit.push(cpu);
                }

                for (let i = 1; i <= anzahlProzesse; i++) {
                    let ak = $("#akzeit" + i).val();
                    ankunftszeit.push(ak);
                }
            } else if ($("#sjf, #rr").data("clicked")) {
                for (let i = 1; i <= anzahlProzesse; i++) {
                    let cpu = $("#prozess" + i).val();
                    cpuLaufzeit.push(cpu);
                }
            }
}

Aucun commentaire:

Enregistrer un commentaire