數據的表中的第一行應是在字體顏色白色,而數據的表中的其餘部分應是在字體顏色橙色。
問題:
在這一點上,數據的整個行是橙色,這是無法設置數據的第一行是橙色,而數據的其餘部分是白色。什麼是問題?請幫忙。
var data = "A,4.0,00:[email protected],5.0,00:[email protected],9.0,00:09";
var playerList = data.split("@");
var innerList;
for (i = 0; i < playerList.length; i++) {
var [name, , score] = playerList[i].split(",");
var [minute, second] = score.split(":");
$("#Player_Name")
.html(function(index, html) {
var prop = index === 0 ? name : score;
return html + prop + "<br>"
})
$("#Player_Minute_Score, #Player_Second_Score").html(function(index, html) {
var prop = index == 0 ? minute : second;
return html + prop + "<p>"
})
}
#Rugby_Scoreboard {
position: absolute;
left: 335px;
top: 182px;
width: 825px;
height: 818px;
border-collapse: collapse;
}
#Rugby_Scoreboard div {
z-index: 50;
position: absolute;
top: 10px;
font-size: 40px;
font-family: 'OpenSans-Bold';
width: 1080px;
color: #ff8c04;
}
#Rugby_Scoreboard div font {
display: block;
}
#Rugby_Scoreboard div font:first-child {
color: white;
}
#Player_Name {
left: 120px;
}
#Player_Minute_Score {
left: 580px;
}
#Player_Second_Score {
left: 700px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="Game_LeaderBoard" style="position:absolute; z-index:6; top:0px; left:0px; width: 1920px; heigth: 1000px; margin:auto;">
<table id="Rugby_Scoreboard">
<tr>
<td>
<div id="Player_Name">
<font face="OpenSans-Bold"></font>
</div>
</td>
<td>
<div id="Player_Minute_Score">
<font face="OpenSans-Bold"></font>
</div>
</td>
<td>
<div id="Player_Second_Score">
<font face="OpenSans-Bold"></font>
</div>
</td>
</tr>
</table>
</div>
'變種[名,成績]'它有兩個逗號。這是一個錯字嗎? – Jai
@Jai沒有,這是研討,因爲我不打算給任何數組變量分配給數組 – Luke
的中間數據,您可以請包括足夠的代碼來重現問題?你有未定義的變量(數據)在這裏,我猜你也使用jQuery,但不能確定。 – TylerH