我试图在jQuery中随机处理8张卡,但每当我在8张卡发出后运行我的代码时,浏览器就会崩溃.它说我在while循环中的第144行有问题.我做了这个循环来处理八个独特的随机卡.
var n = 0
var card = [{id: 1}, {id: 2}, {id: 3}, {id: 4}, {id: 5}, {id: 6}, {id: 7}, {id: 8}];
var arr = [];
var n = Math.floor((Math.random() * 7) + 1);
doOne(0, n);
function doOne(index, rand) {
var thisCard = card[index];
var p = $("#hand1_" + thisCard.id);
var offset = p.offset();
var zindex = p.css('z-index');
if (thisCard) {
$('#card' + rand).css('z-index', zindex);
$('#card' + rand).animate({
top: offset.top,
left: offset.left,
},
function() {
arr.push(rand);
k = …Run Code Online (Sandbox Code Playgroud) 尝试显示错误消息,以便当用户输入错误三次时,将显示错误消息"帐户被阻止".为什么每次输入错误的引脚时pinAttempts ++都不会加1?
try {
int pinAttempts = 0;
int pin = Integer.parseInt(enterPinJTextField.getText());
if (pinAttempts == 3) {
JOptionPane.showMessageDialog(popupFrame, "Account blocked!");
}
if (pin != PIN) {
pinAttempts++;
JOptionPane.showMessageDialog(popupFrame, "Please enter correct pin!");
} else {
BankAccount application = new BankAccount();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
} catch (NumberFormatException exception) {
JOptionPane.showMessageDialog(popupFrame, "Please enter a number");
}
Run Code Online (Sandbox Code Playgroud)