使用PHP打印函数时,JQuery / JavaScript中的引号


Quotes in JQuery / JavaScript when using PHP print function

我正在调试某人的代码,并遇到了一些新手错误。

现在,当它在Xserve上工作时(或者至少它会忽略它),当它在linux服务器上运行时,它拒绝合作,并在底层敲掉一个函数。

我很确定我在这里需要做的是解决引号:引号的范围似乎是错误的-第一个双引号链接到第三个,第二个链接到第四个。任何想法,非常非常欢迎!

<?php foreach ($years as $id => $title) : ?>
$("#<?php print $id ?>_both").click(function() {
$(".<?php print $id ?>.g, .<?php print $id ?>.b")
.attr("checked", $("#<?php print $id ?>_both").attr("checked"));
});
<?php endforeach; 

引号看起来不错(很糟糕,但还好)。你确定你没有遗漏结束php(最后一行):

<?php foreach ($years as $id => $title) : ?>
$("#<?php print $id ?>_both").click(function() {
$(".<?php print $id ?>.g, .<?php print $id ?>.b")
.attr("checked", $("#<?php print $id ?>_both").attr("checked"));
});
<?php endforeach; ?>