javascript - adding and removing class is not working correctly -


I have a php code where it displays a button from edge:

  & Lt; Table ID = "Options and Answers" category = "Options and Answers" & gt; & Lt; Tr class = "answer" & gt; & Lt; TD & gt; 3. Reply  / TD & gt; & Lt; TD & gt; & Lt ;? Php $ a = Category ("A", "Z"); ? & Gt; & Lt; Table ID = "Address of the answer" & gt; & Lt; TR & gt; & Lt ;? Php $ i = 1; Forex currency ($ one $ key = & gt; $ val) {If ($ i% 7 == 1) echo "<">  Echo "& lt; input type = \" button \ "onclick = \" Click BTN (this); \ "Value = \" $ val \ "id = \" answer ". $ Val." \ "Name = \" answer ". $ Val." Name \ "square = \" answer answer answer batons \ "& gt;"; If ($ i% 7 == 0) resonates " "; $ I ++; }? & Gt; ...   

Now these buttons should stop using ".tbtnsOn" and ".answerbtnsOff"

I have the problem that this button Highlights that should be turned on, but it can not close other buttons (closed) so if the button B was highlighted but now the answer is A and C, then it should only turn on A and C and other All buttons must be closed, but it is not as if button B is still running with A and C Land.

So my question is how can I turn off the button. At this moment it is turning on the right button, but the other button is not shutting down.

The current code below is:

  var reply = $ .map (btn.split (''), function (CRR) {return "#answer" + chr; }) Join (','); $ (North) .removeClass ('answerBtnsOn') addClass ('answerBtnsOff'). . $ (Answer) .addClass ("answerBtnsOn") siblings () addClass ('answerBtnsOff').   

Update:

Here's a way to see what's going on, follow the steps below to use the demo: < / P>

  • Step 1: On the left hand side you will see a green plus button, click this button and a modal window will appear.
  • Step 2: In the Search window you see a search bar in the search bar, type "AAA" and submit.
  • Step 3: You will see that a bunch of search results will appear for you. In the first line, you will see the "Answer" column, which will appear within that row to "B" within that row. Click the "Add" button to add that line.
  • Step 4: Now you will see on the right, the button "B" is highlighted.

    It's on time, but the problem is now coming:

    • Step 5: Click the green green plus button again in the row and Do the same search. Step 6: Add another row this time where "Answer" is "AC" now as you can highlight buttons A and C but Button B is still highlighted, it turned off. should go.

      So my problem is, why not turn off the button "B" in this example because it is no longer the answer?

      Instead of deleting the square, the code variable, I think You need to remove the square from all the items containing the class answerBtnsOn .

        $ ('.answerbtnsOn') RemoveClass ('answerBtnsOn') .addClass ('answerBtnsOff');   

      Do this first, because it removes all instances of that class, then by adding the answers to the class that are necessary for it.

      What you already have about this is idea about improving.

Comments