0
我想選擇2個屬性,這些屬性在多項選擇測驗中是可變的。我在input
中回答了每個問題的正確答案,該答案不會顯示在頁面上。我認爲我選擇2種不同屬性的路線是問題所在。
JQUERY:Jquery多屬性選擇器不工作
var zz = 1;
while (zz <= <?php echo $num_rows ?>){ //I'm 100% postive $num_rows returns a value of 3
var zstring = '#answer' + zz;
var theanswer = $(zstring).attr('value'); //should return "a" or "c" or whatever the answer is
if $("input[name=zz][value=theanswer]").is(':checked') { //this is the line that's not working
alert("the code worked");
}
zz++;
}
HTML從PHP
echo "<input type='radio' name=" . $question_number ." value='a'> A. " . $chA . "<br><br>";
echo "<input type='radio' name=" . $question_number ." value='b'> B. " . $chB . "<br><br>";
echo "<input type='radio' name=" . $question_number ." value='c'> C. " . $chC . "<br><br>";
echo "<input type='radio' name=" . $question_number ." value='d'> D. " . $chD . "<br><br>";
echo "<input type='radio' name=" . $question_number ." value='e'> E. " . $chE . "<br>";
echo "<input type='text' id='answer".$question_number."' style='display: none;' value='".$correct."' />";
我誤會了問題,這裏是你的答案小提琴https://jsfiddle.net/h5s7bn1v/4/ –