Got a bunch of letter buttons in code below:
<?php
$a = range("A","Z");
?>
<table id="answerSection">
<tr>
<?php
$i = 1;
foreach($a as $key => $val){
if($i%7 == 1) echo"<tr><td>";
echo"<input type=\"button\" onclick=\"btnclick(this);\" value=\"$val\" id=\"answer".$val."\" name=\"answer".$val."Name\" class=\"answerBtns answers answerBtnsOff\">";
if($i%7 == 0) echo"</td></tr>";
$i++;
}
?>
</tr>
</table>
Now the code below is able to turn on an answer button:
$('#answer'+btn).addClass("answerBtnsOn");
But what I want to do is to be able to turn some answer buttons on and turn the other answer buttons off.
For example if the Answer is A, then I want button “A” to turn on which the above line of code does but I want all of the other letter buttons to turn off. How can I turn off the other letter buttons?
The code here will turn off the letter buttons addClass("answerBtnsOff");,
UPDATE:
I have a little problem as well. If the “Answer” is A, then the letter button “A” is turned on which is fine, but if the Answer is “B D”, then it should turn on letter buttons “B” and “D” but instead it doesn’t turn any buttons on. Does anybody know why this is?
Try the following selector combination: