<!DOCTYPE html> <html> <head> <meta charset='UTF-8'> <title>click</title> <script type="text/javascript" src='jquery-2.2.0.min.js'></script> <style type="text/css"> div{ 200px; height:200px; background-color:red; } </style> </head> <body> <div class='box'> hello </div> <div class='box box1'> hello </div> </body> <script type="text/javascript"> $('.box').click(function(){ alert(1111); }) $('.box.box1').click(function(){ alert(3333) }) </script> </html>
点击.box会出现1111
点击.box.box1的时候出现1111 3333弹出两次