SHOW:
|
|
- or go back to the newest paste.
1 | - | $("div.hidden").click(function(){ |
1 | + | $("div.hidden").click(function(){ |
2 | - | $(this).addClass("orange"); |
2 | + | $(this).addClass("orange"); |
3 | }); | |
4 | - | |
4 | + | |
5 | - | $("div.orange").click(function(){ |
5 | + | $("div.orange").click(function(){ |
6 | - | $(this).removeClass("orange"); |
6 | + | $(this).removeClass("orange"); |
7 | }); | |
8 | - | |
8 | + | |
9 | - | |
9 | + | |
10 | - | <div class="hidden"></div> |
10 | + | <div class="hidden"></div> |
11 | - | |
11 | + | |
12 | - | .hidden{ |
12 | + | .hidden{ |
13 | - | width:100px; |
13 | + | width:100px; |
14 | - | height:100px; |
14 | + | height:100px; |
15 | - | float:left; |
15 | + | float:left; |
16 | - | background-color:#ccc; |
16 | + | background-color:#ccc; |
17 | - | margin-bottom:5px; |
17 | + | margin-bottom:5px; |
18 | - | margin-right:5px; |
18 | + | margin-right:5px; |
19 | - | } |
19 | + | } |
20 | - | |
20 | + | |
21 | .orange {background-color:#F90;} | |
22 | ||
23 | - | $("div.hidden orange").click(function(){ |
23 | + | $("div.hidden orange").click(function(){ |
24 | - | $(this).removeClass("orange"); |
24 | + | $(this).removeClass("orange"); |
25 | }); | |
26 | ||
27 | - | $("div").click(function(){ |
27 | + | $("div").click(function(){ |
28 | - | $(this).toggleClass("orange"); |
28 | + | $(this).toggleClass("orange"); |
29 | }); | |
30 | ||
31 | - | var $div = $('div.hidden'); |
31 | + | var $div = $('div.hidden'); |
32 | - | if ($('div.hidden').hasClass('orange')) { |
32 | + | if ($('div.hidden').hasClass('orange')) { |
33 | - | $div.removeClass('orange'); |
33 | + | $div.removeClass('orange'); |
34 | - | } |
34 | + | } |
35 | else $div.addClass('orange'); | |
36 | ||
37 | - | $("div.hidden").click(function(){ |
37 | + | $("div.hidden").click(function(){ |
38 | - | if ($(this).hasClass("orange")) { |
38 | + | if ($(this).hasClass("orange")) { |
39 | - | $(this).removeClass("orange"); |
39 | + | $(this).removeClass("orange"); |
40 | - | } else { |
40 | + | } else { |
41 | - | $(this).addClass("orange"); |
41 | + | $(this).addClass("orange"); |
42 | - | } |
42 | + | } |
43 | }); | |
44 | ||
45 | - | $("div.hidden").click(function(){ |
45 | + | $("div.hidden").click(function(){ |
46 | - | $(this).toggleClass("orange"); |
46 | + | $(this).toggleClass("orange"); |
47 | }); |