javascript - Jquery write on the fly in a div -


I am trying to create a Sudoku game using jquery and php I have all the game logic, End of work. So what I need to do is click on an empty cell, which will be a div that will activate that div. Then use the number on the key board to enter the number that the user wants. If they want, they have to be able to remove them.

Any thoughts? I have used jquery before but there is no clue as to where to start with it

nick

I do not necessarily support the use of such plugins functionality, what you can do with basic jquery, assume that you have such structure:

  & lt; Div & gt; 7 & lt; / Div & gt; & Lt; Div & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt; / Div & gt; ...  

You can do the following:

  $ ("div"). Click (function (i, div) {if ($ (Div) .find ("input") {// is already editing an element, go back to return;} var number = $ (div). Text (); $ (div) .empty.append ($ ("& lt; input"; "input".) () "Input input.attr" ("value", number);} input.keyup (function (Return) e) {if press enter var value = parseInt ($ (this) .value (), 10); if (value) {$ (this) .Parent () Empty () .text (value);} else {// Sorry friend, display error message or anything else}}}}}  

Clicks on what the code does To div a Changes the content, the number was already filled beforehand, and when the user enters the press, he checks the input and changes the input through the text.

I'm writing from my head, sorry for any syntax errors, the meaning should be clear.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -