W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <head> <script type="text/javascript" src="/jquery/jquery.js"></script> <style> li { margin: 3px; padding: 3px; background: #EEEEEE; } li.hilight { background: yellow; } </style> </head> <body> <ul> <li><b>Click me!</b></li> <li>You can also <b>Click me!</b></li> </ul> <script> $( document ).bind("click", function( e ) { $( e.target ).closest("li").toggleClass("hilight"); }); </script> </body> </html>