JSON データを使用してリストをループし、HTML の LI 行を作成しています。問題は、JQuery の追加を使用する場合、クラス名が Web ブラウザーに顕著な影響を与えないことです。(クラス名が存在しないかのようです)。
月額プラン #6 には背景色がありません。つまり、クラス名が正しく使用または追加されていません。
ここで何が問題になっているようですか?
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title></title>
<style type="text/css">
li
{
margin: 0px 0px 0px 0px;
border-top: solid 1px #000000;
border-left: solid 1px #000000;
border-right: solid 1px #000000;
padding: 0px 0px 0px 0px;
list-style: none;
}
ul
{
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
border: solid 0px #000000;
list-style: none;
}
ul li.liFirstChild
{
border-bottom: solid 0px #000000;
-webkit-border-top-left-radius: 14px 14px;
-webkit-border-top-right-radius: 14px 14px;
-webkit-border-bottom-left-radius: 0px 0px;
-webkit-border-bottom-right-radius: 0px 0px;
-moz-border-radius-topleft: 14px;
-moz-border-radius-topright: 14px;
-moz-border-radius-bottomleft: 0px;
-moz-border-radius-bottomright: 0px;
border-radius: 14px 14px 0px 0px;
}
ul li:last-child, ul li.liLastChildTrue
{
border-bottom: solid 1px #000000;
-webkit-border-bottom-left-radius: 14px 14px;
-webkit-border-bottom-right-radius: 14px 14px;
-moz-border-radius-bottomleft: 14px;
-moz-border-radius-bottomright: 14px;
border-radius: 0px 0px 14px 14px;
background-color: #ff0000;
}
ul li.liLastChildFalse
{
-webkit-border-bottom-left-radius: 0px 0px;
-webkit-border-bottom-right-radius: 0px 0px;
-moz-border-radius-bottomleft: 0px;
-moz-border-radius-bottomright: 0px;
border-radius: 0px 0px 0px 0px;
border-bottom: solid 0px #ffffff;
background-color: #ff00ff;
}
</style>
<script type="text/javascript" src="/Member/Scripts/jquery-v2.0.3/jquery-v2.0.3.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var _dataHtmlRow = { "Booklet": [{ "Id": "0", "Schedule": "12 Payments", "Year": "1", "PaymentAmount": "$2.00" }, { "Id": "1", "Schedule": "18 Payments", "Year": "1.5", "PaymentAmount": "$4.00" }, { "Id": "2", "Schedule": "24 Payments", "Year": "2", "PaymentAmount": "$6.00" }, { "Id": "3", "Schedule": "30 Payments", "Year": "2.5", "PaymentAmount": "$8.00" }, { "Id": "4", "Schedule": "36 Payments", "Year": "3", "PaymentAmount": "$10.00" }, { "Id": "5", "Schedule": "42 Payments", "Year": "3.5", "PaymentAmount": "$12.00" }] };
//Calculate Quick Quote - Button...
$('#buttonCalculateQuickQuote').on('click', function (e) {
var htmlRow = "";
var $divGridViewer = $('#divGridViewer');
$divGridViewer.empty();
$divGridViewer.append("<ul>");
$.each(_dataHtmlRow.Booklet, function (i, o) {
htmlRow = "";
htmlRow += "<li " + (i == 0 ? "class='liFirstChild'" : "") + " style='background-color:#FFA94C;'>";
htmlRow += " <div style='float:left;'>Monthly Plan #" + (i + 1).toString() + "</div>";
htmlRow += " <div style='clear:both;'></div>";
htmlRow += "</li>";
htmlRow += "<li>";
htmlRow += " <div style='float:left;'>Schedule: </div>";
htmlRow += " <div style='float:right;'>" + o.Schedule + "</div>";
htmlRow += " <div style='clear:both;'></div>";
htmlRow += "</li>";
htmlRow += "<li>";
htmlRow += " <div style='float:left;'>Year: </div>";
htmlRow += " <div style='float:right;'>" + o.Year + "</div>";
htmlRow += " <div style='clear:both;'></div>";
htmlRow += "</li>";
htmlRow += "<li class='" + (i == (_dataHtmlRow.Booklet.length - 1) ? "liLastChildTrue" : "liLastChildFalse") + "'>";
htmlRow += " <div style='float:left;'>Payment Amt: </div>";
htmlRow += " <div style='float:right;'>" + o.PaymentAmount + "</div>";
htmlRow += " <div style='clear:both;'></div>";
htmlRow += "</li>";
$divGridViewer.append(htmlRow);
});
$divGridViewer.append("</ul>");
return false;
});
});
</script>
</head>
<body>
<div style="padding:25px;">
<div style="padding-bottom:20px;">
<input type="button" id="buttonCalculateQuickQuote" value="Calculate Quick Quote" style="" />
</div>
<div>
<div id="divGridViewer">
</div>
</div>
</div>
</body>
</html>