$('#timetable td').each(function(){ $(this).click(function(){ if($(this).html()=="√"){ $(this).css("background-color","white"); $(this).text(""); }else { $(this).css("background-color", "#96b8ff");//设置点击td的颜色 $(this).text("√"); } }); });
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.youkuaiyun.com/jiangjunshow
本文介绍了一种使用jQuery操作HTML表格的方法,通过遍历并为每个单元格(td)添加点击事件,实现对表格中单元格状态的切换。点击后,单元格背景颜色将发生变化,并显示或清除标记符号。
3255

被折叠的 条评论
为什么被折叠?



