Hot answers tagged

2

JavaScript $.get is asynchronous. It triggers an HTTP request and returns. The code meant to prevent submission runs after submission is processed, and therefore can't prevent it. The preventDefault has to go into the submit handler, not the $.get callback, and would be called each time you try to submit, cancelling the submit attempt. Inside the get ...


2

.focus(handler) is short for .on("focus", handler), and installs an event listener, in your case, handler is an anonymous function declared with one parameter. Those handlers, when called, receive an event object. It has some properties and methods that might be interesting, in my opinion some of the most valuable are target, preventDefault, and ...


1

Use semicolon wherever you mean it. Your IIFE is interpreted as a function call, like some_expression // missing semicolon here leads to misinterpretation (function(){ /* do something */ }());


1

[UPDATE 18/07/2017] Instead use: $("main").on("click", ".delete", function() { (this).closest(".card").remove(); }); The issue is associated with the creation of dynamic elements. The jQuery syntax to register clicks on dynamically created buttons or similar is slightly different. For these cases use the general form of: $(<wrapper>).on("click"...


1

Assume grid size 3 and hyp_board 0 | 0 | -1 0 | 0 | 0 1 | 0 | 1 The first "check each row" loop will return 1 as the winner. Won't it? "On paper" from i = 2: first_node = hyp_board[2][0] = 1. j = 1. winner = hyp_board[2][1] = 0. 1 != 0, winner = 0. j = 2. winner = hyp_board[2][2] = 1. 1 == 1. winner != 0, return winner (1).


1

The return value of a successful $mysqli->query involving INSERT is true (it does not return an object), so you can test for this and echo a corresponding message.


1

It is an object method. See getJSON api doc especially The jqXHR Object section. This article on jQuery chaining explains why it looks like the methods are "not attached to an object".


Only top voted, non community-wiki answers of a minimum length are eligible