[英]How can I make a if and else-if statement in jQuery for is clicked
What can I solve this problem with if-else? 我可以用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);
}
}
}
Unless I'm missing something you don't need an IF. 除非我缺少任何东西,否则您不需要IF。
$("#fcfs, #srtf").on('click') {
is an event Listener that is triggered when the click is registered / detected. 是事件侦听器,当注册/检测到点击时触发。
So anything you want to happen when there is a click, just put inside the onclick function 因此,只要单击一下,您想发生的任何事情都可以放在onclick函数中
$("#fcfs, #srtf").on('click')) {
// DO SOME STUFF HERE
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.