Advertisement
Guest User

Untitled

a guest
Jan 29th, 2014
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. $("div.hidden").click(function(){
  2. $(this).addClass("orange");
  3. });
  4.  
  5. $("div.orange").click(function(){
  6. $(this).removeClass("orange");
  7. });
  8.  
  9.  
  10. <div class="hidden"></div>
  11.  
  12. .hidden{
  13. width:100px;
  14. height:100px;
  15. float:left;
  16. background-color:#ccc;
  17. margin-bottom:5px;
  18. margin-right:5px;
  19. }
  20.  
  21. .orange {background-color:#F90;}
  22.  
  23. $("div.hidden orange").click(function(){
  24. $(this).removeClass("orange");
  25. });
  26.  
  27. $("div").click(function(){
  28. $(this).toggleClass("orange");
  29. });
  30.  
  31. var $div = $('div.hidden');
  32. if ($('div.hidden').hasClass('orange')) {
  33. $div.removeClass('orange');
  34. }
  35. else $div.addClass('orange');
  36.  
  37. $("div.hidden").click(function(){
  38. if ($(this).hasClass("orange")) {
  39. $(this).removeClass("orange");
  40. } else {
  41. $(this).addClass("orange");
  42. }
  43. });
  44.  
  45. $("div.hidden").click(function(){
  46. $(this).toggleClass("orange");
  47. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement