javascript - Changing adjacent cells in table when an event is triggered in JQuery -
I am trying to create a game of light. When I click on them, I can toggle the light off and shut down, but there is a problem in thinking the argument to make the adjacent one the same. For example, if I click on one edge of the table, So I should see three lights near the light, I became ill. I am thinking that this is something to force "this" in my click method, maybe "this" refers to only one I click on and not for adjacent people. I need to know, perhaps how to get it in the context of the impending people?
& lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Lite out! & Lt; / Title & gt; & Lt; Script type = "text / javascript" src = "jquery-1.4.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; Var gameBoard = new GetTdCount () function lightstats (status) {// if the light is on (gameBoard [position] == true) {// Set original position back in false game [position] [position] = Incorrect; Return false) // Turn on the Light gameBoor [status] = true; Return gameboard [status]} function getTdCount () {return $ ("TD") Length; } Function getTrCount () {return $ ("tr"). Length; } {0} ($ ("img", obj) .attr ('src', 'on.png')} and {$ ("IMG", OBG) ARTR ('src', 'off.png')} } $ (Document) .ready (function () {$ ("# trtr td"). Hover (function () {$ (this) .css ('border -color', '00FFCC');}, function ) $ $ (This). CSS ('border-color', 'black')}) $ offProtoType = $ ('# offprototype'). CSS ('Display $ Tds.click (function () {var num ==} $ '($') '$' $ Tds.index (this) + 1; Switchlights (this, number)})}); & lt; / script & gt; style type = "text / css" & Gt; TD {border-style: solid; border-color: black; background color: black; swim left;} body White color: gray; green color;} gt; & gt; & gt; & gt; body & gt; & lt; img style = "display: none" id = "offprototype" Src = "off.png"> lt; img style = "display: none" id = "onprototype" src = "on.png" & gt; & lt; h1 align = "center"> light Out & lt; h1 & gt; Table ID = "Board" limit = "3" bgcolor = "black" align = "center"> & lt; tr & gt; & lt; td & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; Input type = "button" value = "drag" onclick = "change ()" /> & Lt; / Body & gt; & Lt; / Html & gt; $ (This) .next () and $ (this) .prev (
post = "post-text" itemprop = "text">
) To get a reference to the next & amp; last.
You get $ (this) to get the status of 'this' among your brothers. You can use index (); Then use something like Ebauch and Bottom to the bottom.
var pos = $ (this) .index (); Var prevRow = $ (this). Parent (). Prev ('tr'); Up = Prevalent & amp; Amp; PrevRow.children () Piece (POS). Var nextRow = $ (this). Parent (). Next ('tr'); Var Below = Pravan & amp; PrevRow.children () Piece (POS).
Comments
Post a Comment