根据明细中的项目分组 来进行背景色设置
/**
* 取引先コードによる色を設定
*/
function background() {
// 取引先コードのリストを取得する
var torihikiList = $('#meiSaiTable tr td:nth-child(4)');
var tem = "";
for (i = 0; i < torihikiList.length; i++) {
// 取引先コードによる色を設定
if (torihikiList[i].innerText == tem) {
addClass($('#meiSaiTable tr')[i + 1],$('#meiSaiTable tr')[i].className);
tem = torihikiList[i].innerText;
} else {
if (i == 0 || $('#meiSaiTable tr')[i].className == "color1") {
addClass($('#meiSaiTable tr')[i + 1], "color2");
} else {
addClass($('#meiSaiTable tr')[i + 1], "color1");
}
tem = torihikiList[i].innerText;
}
}
}
function hasClass(e, c) {
var classes = e.className;
if (!classes)
return false;
if (classes == c)
return true;
return e.className.search("\\b" + c + "\\b") != -1;
}
function addClass(e, c) {
if (hasClass(e, c))
return;
if (e.className)
c = " " + c;
e.className += c;
}
jsp中链接外部js css
<script type="text/javascript" src="${pageContext.request.contextPath}/common/js/torihikisaki/ryutsuShinseiSearch.js" charset="UTF-8"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath}/common/css/dounyunShinsei.css" type="text/css" />