<!doctype html> <html lang="en"> <head> <title>JavaScript Editor</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta charset="utf-8"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> </head> <body> <div id="page"></div> <textarea id="editor"></textarea> <script> $("#editor").val(localStorage.html) // editor <- var $("#page").html(localStorage.html) // page <- var function sync(){ localStorage.html=$('#editor').val(); // var <- editor $("#page").html(localStorage.html) // page <- var } </script> <button onclick="sync()">sync</button> </body> </html>