我使用codeigniter,CSS和JQuery。我想在1分钟后改变一行的背景颜色。在更新操作1分钟后,该行将像其他行一样获得默认颜色。
任何想法,任何功能,任何人都可以帮助!
感谢您的帮助。
答案 0 :(得分:1)
启动setTimeout
功能
// maybe you could give the row a class such as .updated
var row = $('table tr.updated');
updateRow(row);
// or maybe the updated row is always the last one?
var row = $('table tr').last();
updateRow(row);
function updateRow(row)
{
// do all the stuff associated with updating the row
// note that you're going to actually have to find row yourself or
// pass it in as an element
$(row).css('background-color', 'red');
setTimeout(function() {
$(row).css('background-color', your default color);
}, 60000);
}
答案 1 :(得分:0)
您必须使用setTimeout(function, miliseconds)
例如:
function setColorTemporary(obj) {
$(obj).css("background-color", "blue");
setTimeout(function()
{
$(obj).css("background-color", "transparent");
}, 60000); //60 seconds
}
setColorTemporary($("#id987")); //Set color for any object for 1 minute
在控制器中,也许......
<?php
class MyController extends CI_Controller {
public function method()
{
$id = "#id987";
echo "<script>setColorTemporary($('$id'));</script>";
}
}