Conflict between body-wide replace function in toggle function inside the body tag

Conflict between body-wide replace function in toggle function inside the body tag

Hi,
I like to realise a multilingual surface of my cms. Therefore I like to use the replace function.
The problem is, I use a toggle function which is placed inside the body tag. Both together do not function.

How can I solve this problem. I need the toggle function inside the body Tag

  1. <body>
      <div class="switch">switch</div>

      <div class="show">Text</div>
     
       <script type="text/javascript">
      $('div.switch').click(function () {
         $('div.show').toggle();
          });
         
        
     
      var replaced = $("body").html().replace('switch', 'open');
      $("body").html(replaced);
     

      </script>
     
     
      </body>