Focus Blur problem

Focus Blur problem

I need to change background color depending on the visibility of dropdown list.
Can anyone help? It won't turn to red when I click outside of the menu.



  1. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  2.  
  3. <script>
  4. $(document).on('click','body', function(){
  5.       if(jQuery(".selector").is(":focus")){
  6.              $("body").css("background-color","green");
  7.             } else{
  8.                $("body").css("background-color","red");
  9.       }
  10. });

  11. </script>

  12. <html>
  13.  <select class="selector">

  14.     <option value="berlin" data-calculation="0">Berlin</option>
  15.     <option value="london" data-calculation="0">London</option>
  16.     <option value="sydney" data-calculation="0">Sydney</option>
  17.     <option value="tokyo" data-calculation="0">Madagaskar</option>
  18. </select>
  19. </html>