change the background color of class

change the background color of class

How to make that when you click on class fon of box1, the background color of class sun of box1 must to changes, and when you click on class fon of box2, the background color of class sun of box 2 must to changes. At the moment, the background color of boxes 1 and 2 is changing, although  only click on one of the boxes.

  1.  <style>
  2. .container {
  3.   display: flex;           
  4.           }
  5. .sun{
  6.     margin-top: -6rem;
  7.     margin-left: auto;
  8.     margin-right: auto;
  9.     width: 10rem;
  10.     height: 14rem;
  11.     background-color: orange;
  12. }
  13. .fon{
  14. background-color:green;
  15. width: 9rem;
  16. height: 9rem;
  17. }
  18. .d19{
  19. background-color:blue;
  20. width: 10rem;
  21. height: 11rem;
  22. }
  23. h1{padding-top:5rem;
  24. }
  25. </style>
  26. <script src="jquery-3.4.1.js"></script>
  27. </head>
  28. <body >
  29. <div class='container'>
  30. <div class='sun'>
  31. <div class="d19" >
  32. <div class='fon'>
  33. <h1>1 box</h1>
  34. </div>
  35. </div>
  36. </div>
  37. <div class='sun'>
  38. <div class="d19" >
  39. <div class='fon'>
  40. <h1>2 box</h1>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <script>
  46. $( document ).ready(function(){
  47. $('.fon').mouseup(function() {
  48. $('.sun').css({'background-color':'yellow'});
  49.     });
  50. });
  51. </script>
 








1 box

2 box