1 | <style type="text/css"> |
---|
2 | .parentC{width:350px; background:#ccc; border:1px solid #000; height:200px;} |
---|
3 | .child1-0{width:40%; float:left; border:1px solid #999; background:#ff0000; height:125px;} |
---|
4 | .child1-1{width:40%; float:right; border:1px solid #999; background:#ff0000; height:125px;} |
---|
5 | .child2-0{width:40%; float:left; border:1px solid #999; background:#fff; height:75px;} |
---|
6 | .child2-1{width:40%; float:right; border:1px solid #999; background:#fff; height:75px;} |
---|
7 | </style> |
---|
8 | <div id="parentD" class="parentC">Parent |
---|
9 | <div id="child0" class="child1-0">Child 0</div> |
---|
10 | <div id="child1" class="child1-1">Child 1 |
---|
11 | <div id="child1_0" class="child2-0">Child 1.0</div> |
---|
12 | <div id="child1_1" class="child2-1">Child 1.1</div> |
---|
13 | </div> |
---|
14 | </div> |
---|
15 | <script type="text/javascript"> |
---|
16 | $(function(){ |
---|
17 | $('#parentD').click(function(){ |
---|
18 | alert($(this).attr('class')); |
---|
19 | }); |
---|
20 | $('#child0').click(function(){ |
---|
21 | alert($(this).attr('class')); |
---|
22 | }); |
---|
23 | $('#child1').click(function(){ |
---|
24 | alert($(this).attr('class')); |
---|
25 | }); |
---|
26 | $('#child1_0').click(function(){ |
---|
27 | alert($(this).attr('class')); |
---|
28 | }); |
---|
29 | $('#child1_1').click(function(){ |
---|
30 | alert($(this).attr('class')); |
---|
31 | }); |
---|
32 | }); |
---|
33 | </script> |
---|