时间:2024-01-09 12:36:01 | 来源:网站运营
时间:2024-01-09 12:36:01 来源:网站运营
如何制作每日任务网页?:首先,这是一个网页,那么应该先写出网页的基本结构<!DOCTYPE html><html><head><meta charset="utf-8" /><title>每日任务</title></head><body></body></html>
接下来,在网页主体内容body里要写一个每日任务的列表,每一个列表项要做到点击之后该项消失,即<ul class="renwu"> <li class="renwu-li" id="renwu001"> <span class="renwu-left">任务001</span> <span class="renwu-right"><button class="anniu" onclick="anniu001()">完成</button></span> </li><script>function anniu001(){ document.getElementById("renwu001").style.display = "none";}</script></ul>
重复上述内容可以得到多个任务,但是这个页面在刷新之后会恢复为初始状态,如何修改可以让其刷新之后不恢复初始状态,能依然保持已完成的任务状态,暂时不知如何去做,欢迎留言指教。有其他思路的也欢迎留言评论。<ul class="renwu"> <li class="renwu-li" id="renwu1"><span class="renwu-li-left">任务001</span><button class="renwu-li-right" onclick="anniu1(1)">完成</button></li> <li class="renwu-li" id="renwu2"><span class="renwu-li-left">任务002</span><button class="renwu-li-right" onclick="anniu1(2)">完成</button></li> <li class="renwu-li" id="renwu3"><span class="renwu-li-left">任务003</span><button class="renwu-li-right" onclick="anniu1(3)">完成</button></li> <li class="renwu-li" id="renwu4"><span class="renwu-li-left">任务004</span><button class="renwu-li-right" onclick="anniu1(4)">完成</button></li> <li class="renwu-li" id="renwu5"><span class="renwu-li-left">任务005</span><button class="renwu-li-right" onclick="anniu1(5)">完成</button></li></ul><script>function anniu1(x){ document.getElementById("renwu" + x).style.display = "none";}</script>
<!DOCTYPE html><html><head><meta charset="utf-8" /><title>每日任务</title></head><body><ul class="renwu"> <li class="renwu-li" id="renwu1"><span class="renwu-li-left">任务001</span><button class="renwu-li-right" onclick="anniu1(1)">完成</button></li> <li class="renwu-li" id="renwu2"><span class="renwu-li-left">任务002</span><button class="renwu-li-right" onclick="anniu1(2)">完成</button></li> <li class="renwu-li" id="renwu3"><span class="renwu-li-left">任务003</span><button class="renwu-li-right" onclick="anniu1(3)">完成</button></li> <li class="renwu-li" id="renwu4"><span class="renwu-li-left">任务004</span><button class="renwu-li-right" onclick="anniu1(4)">完成</button></li> <li class="renwu-li" id="renwu5"><span class="renwu-li-left">任务005</span><button class="renwu-li-right" onclick="anniu1(5)">完成</button></li></ul><script>function anniu1(x){ document.getElementById("renwu" + x).style.display = "none";}</script></ul></body></html>
关键词:任务