Jquery 多属性选择器不工作

Jquery Multiple Attribute Selector not working

我正在尝试 select 2 个在多项选择测验中可变的属性。我在页面上没有显示的 input 中重复了每个问题的正确答案。我认为我 select 用于 2 个不同属性的行是问题所在。
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."' />";

我看到在 if 语句中你有这个:

if $("input[name=zz][value=theanswer]").is(':checked') {  //this is the line 

应该是:

if ($('input[name="zz"][value="theanswer"]').is(':checked')) {  //this is the line