:
$(document).ready(function()
{
$("#myTable").tablesorter();
setAllDifferentHeight();
highlight();
}
);
function highlight()
{
var firsts = document.getElementsByClassName("first");
for(var i=0; i<firsts.length; i++){
firsts[i].style.backgroundColor = "gold";
}
var seconds = document.getElementsByClassName("second");
for(var i=0; i<seconds.length; i++){
seconds[i].style.backgroundColor = "silver";
}
var thirds = document.getElementsByClassName("third");
for(var i=0; i<thirds.length; i++){
thirds[i].style.backgroundColor = "brown";
}
var lasts = document.getElementsByClassName("last");
for (var i = lasts.length - 1; i >= 0; i--) {
lasts[i].style.backgroundColor = "pink";
}
}
来自index.blade.php的:
@foreach($student as $s)
<?php $sum = $s->mc+$s->tc+$s->hw+$s->bs+$s->ks+$s->ac; ?>
@if($sum == $first)
<tr class = "first">
@elseif($sum == $second)
<tr class = "second">
@elseif($sum == $third)
<tr class = "third">
@elseif($sum == $last)
<tr class = "last">
@endif
HTML是在正确的位置使用正确的类生成的,但javascript不会突出显示。当我在控制台中运行Javascript代码时,它会执行我想要的操作。这是什么问题?