ajax - Javascript moving cursor on table that is editable move on save row -


I have a JavaScript where a cursor is inserted up, down, on a table. It works, but I want to move the cursor left and right on the same line. How can I go about doing this?

I tried and it does not work:

  else if (evt.keyCode == 39) {event.preventDefault (); Var cell index = $ (this). Index () var rowindex = $ (this) .parents ('td'). Index () + 1 $ (this) .parents ('table') ('Tr: eq search' '+ + +' + '+' +) TD: eq ('+ cell index +') ''. Focus ()}   

This is the work code for up, down.

  jQuery (document) .ready (function () {$ ('td'). Keydown (function (evt) {if (evt.keyCode == 40) {event.preventDefault () ; var cell index = $ (this). index () var rowindex = $ (this) .parents ('tr'). index () + 1 $ (this) .parents ('table'). ('tr: eq ('+ Rowindex +'). Td: eq ('+ cellindex +') '). Focus ()} and if (evt.keyCode == 38) {event.preventDefault (); var cell index = $ (this ) .index () var rowindex = $ (this) .Parents ('tr'). Index () - $ 1 (this) .Prints ('Table'). ('Tr: eq (' + rowindex + ') TD : Eq ('+ cell index +') ''). Focus ()} and if (evt.keyCode == 13) {event.preventDefault (); var cell index = $ (this). Index () var rowindex = $ (This) .parents ('tr ') Index () + 1 $ (this) .parents (' table '). (' Tr: eq ('+ rowindex +') TD: eq ('+ +' cellindex + ')' '). }}}});    

After this last code, add it to your code else if (evt Key code == 13) {:

  // other key handlers [...]} else if (evt.keyCode = = 39) {event.preventDefault (); Var rowindex = $ (this) .parents ('tr'). Index (); Var Selindex = $ (this). Index () + 1; $ (This) .parents ('table') ('Tr: eq (' + rowindex + ') TD: eq (' + + 'cellindex +' '' ') Focus ()} else if (evt.keyCode == 37) {event.preventDefault (); Var rowindex = $ (this) .parents ('tr'). Index (); Var Selindex = $ (this). Index (-1); $ (This) .parents ('table') ('Tr: eq (' + rowindex + ') td: eq (' + + + 'cellindex +' '' ') Focus ()}   

evtKeyCode == 39 is to press the right arrow, evt.keyCode == 37 left arrow Is for

In fact, all you got in order to do this is flipped around the line index and cell index.



Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -