<!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script> <style> </style> </head> <body> <input type="button" id="Hello" value="Hello"> <script> $(function(){ $.print=function(msg){$("<div></div>").html(msg).appendTo('body');}; $("#Hello").click(function(){ $.print("Hello World"); }); }); </script> </body> </html>