jQueryを介してdivのCSSを変更しようとしています。以下はjQueryコードです。
$(".endPollingButton").click(function () {
var endPollingCode = $(this).attr("value");
var correctAnswer = parseInt($(this).attr("id"));
for(LCV=1;LCV<=5;LCV++) {
if(LCV == correctAnswer) {
$("#"+endPollingCode).children(".Bars_"+LCV).css("background-color","green");
alert("check");
} else {
$("#"+endPollingCode).children(".Bars_"+LCV).css("background-color","red");
alert("check");
}
}
});
これがhtmlコードです:
for($LCV = 1; $LCV <= $rowCount; $LCV++) {
echo "<div class='graphBlock' id='".$questionCode[$LCV]."' value=''>";
echo "<div id='questionCodeBar'>Quiz Code: ".$questionCode[$LCV]."</div>";
echo "<div id='questionTitleBar'>".$questionName[$LCV]."</div>";
echo "<span class='barsInfo' id='barsInfo1".$LCV."'></span><div class='bars_1' id='bars1".$LCV."' style='width:;'></div>";
echo "<span class='barsInfo' id='barsInfo2".$LCV."'></span><div class='bars_2' id='bars2".$LCV."' style='width:;'></div>";
echo "<span class='barsInfo' id='barsInfo3".$LCV."'></span><div class='bars_3' id='bars3".$LCV."' style='width:;'></div>";
echo "<span class='barsInfo' id='barsInfo4".$LCV."'></span><div class='bars_4' id='bars4".$LCV."' style='width:;'></div>";
echo "<span class='barsInfo' id='barsInfo5".$LCV."'></span><div class='bars_5' id='bars5".$LCV."' style='width:;'></div>";
echo "<button class='endPollingButton' id='".$correctAnswer[$LCV]."' value='".$questionCode[$LCV]."' >End Polling</button>";
echo "</div>";
}
上記のコードは機能していません。構文エラーがあるかどうかわかりません。両方のチェックアラートが機能しています。これがリンクされているHTMLのようなコードがさらに必要な場合は、お知らせください。喜んで提供させていただきます。できれば助けてください。ありがとう。
お願いします……