{"id":2040,"date":"2025-06-03T19:55:22","date_gmt":"2025-06-03T16:55:22","guid":{"rendered":"https:\/\/html-online.com\/articles\/?p=2040"},"modified":"2025-06-09T15:22:26","modified_gmt":"2025-06-09T12:22:26","slug":"copy-to-clipboard-website-button-jquery","status":"publish","type":"post","link":"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/","title":{"rendered":"Simple &#8220;Copy to Clipboard&#8221; Website Button with jQuery"},"content":{"rendered":"<p><strong>A very simple solution to allow website visitors to copy website content to their clipboard\ud83d\udccb with a single click or tap. Enhance your website&#8217;s user experience adding this feature. Grab the code below or see the <a target=\"_blank\" href=\"https:\/\/jsfiddle.net\/oeuwjbds\/\" rel=\"noopener\">live demo on jsFiddle<\/a>.<\/strong><\/p>\n<p class=\"aligncenter\"><a href=\"\/\"><img decoding=\"async\" src=\"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2024\/06\/new-html-editor-feature-copy-button.jpg\" alt=\"new html editor feature copy button\" \/><\/a><\/p>\n<p><!--more--><\/p>\n<p>We have just added this button to our <a href=\"\/\">online HTML editor<\/a>, and I hope you&#8217;ll find it useful. From now on we&#8217;re planning to implement this feature for all <a href=\"\/articles\/category\/tools\/\">our HTML tools<\/a>.<\/p>\n<p>Whether you are a developer, content creator, or an everyday user, having a quick and seamless way to copy text can save valuable time and reduce frustration. Enter the <strong>&#8220;Copy&nbsp;to Clipboard&nbsp;\ud83d\udccb&#8221;<\/strong> button &mdash; an intuitive and efficient tool designed to streamline the process of copying text with a single click. Here, we&#8217;ll explore the implementation details and the benefits of this handy feature, then you can further customize it to match the design of your site.<\/p>\n<h3>HTML Code<\/h3>\n<p>The core of our &#8220;Copy to Clipboard&#8221; button lies in the HTML structure. In our demo we have two text elements that can be copied and a hidden <a target=\"_blank\" rel=\"nofollow noopener\" href=\"https:\/\/html-css-js.com\/html\/tags\/#textarea\">textarea tag<\/a> to facilitate the copying process. Here is the HTML markup:<\/p>\n<div style=\"background: #ffffff; overflow: auto; width: auto; border: solid gray; border-width: .1em .1em .1em .8em; padding: .2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #007700;\">&lt;h1<\/span> <span style=\"color: #0000cc;\">id=<\/span><span style=\"background-color: #fff0f0;\">\"mainTitle\"<\/span><span style=\"color: #007700;\">&gt;<\/span>Click the button to copy this to clipboard<span style=\"color: #007700;\">&lt;\/h1&gt;<\/span>\n<span style=\"color: #007700;\">&lt;span<\/span> <span style=\"color: #0000cc;\">class=<\/span><span style=\"background-color: #fff0f0;\">\"copyButton\"<\/span> <span style=\"color: #0000cc;\">data-target=<\/span><span style=\"background-color: #fff0f0;\">\"#mainTitle\"<\/span><span style=\"color: #007700;\">&gt;<\/span>Copy<span style=\"color: #007700;\">&lt;\/span&gt;<\/span>\n\n<span style=\"color: #007700;\">&lt;h2<\/span> <span style=\"color: #0000cc;\">id=<\/span><span style=\"background-color: #fff0f0;\">\"secondTitle\"<\/span><span style=\"color: #007700;\">&gt;<\/span>Second text you can copy<span style=\"color: #007700;\">&lt;\/h2&gt;<\/span>\n<span style=\"color: #007700;\">&lt;span<\/span> <span style=\"color: #0000cc;\">class=<\/span><span style=\"background-color: #fff0f0;\">\"copyButton\"<\/span> <span style=\"color: #0000cc;\">data-target=<\/span><span style=\"background-color: #fff0f0;\">\"#secondTitle\"<\/span><span style=\"color: #007700;\">&gt;<\/span>Copy<span style=\"color: #007700;\">&lt;\/span&gt;<\/span>\n<span style=\"color: #007700;\">&lt;br&gt;<\/span>\n<span style=\"color: #007700;\">&lt;textarea<\/span> <span style=\"color: #0000cc;\">cols=<\/span><span style=\"background-color: #fff0f0;\">\"10\"<\/span> <span style=\"color: #0000cc;\">id=<\/span><span style=\"background-color: #fff0f0;\">\"copyTextArea\"<\/span> <span style=\"color: #0000cc;\">rows=<\/span><span style=\"background-color: #fff0f0;\">\"1\"<\/span> <span style=\"color: #0000cc;\">spellcheck=<\/span><span style=\"background-color: #fff0f0;\">\"false\"<\/span><span style=\"color: #007700;\">&gt;&lt;\/textarea&gt;<\/span>\n<\/pre>\n<\/div>\n<p>In this structure, each <code>copyButton<\/code> element has a <code>data-target<\/code> attribute pointing to the ID of the text element it will copy from. The hidden textarea (<code>copyTextArea<\/code>) is used to temporarily hold the text to be copied.<\/p>\n<p class=\"aligncenter\"><a target=\"_blank\" rel=\"nofollow noopener\" href=\"https:\/\/jsfiddle.net\/oeuwjbds\/\"><img decoding=\"async\" src=\"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2024\/06\/copy-to-clipboard-button-html-css-jquery.jpg\" alt=\"copy to clipboard button html css jquery\" \/><br \/><strong>Check out the live demo on jsFiddle<\/strong><\/a><\/p>\n<h3>The CSS Style<\/h3>\n<p><a target=\"_blank\" rel=\"nofollow noopener\" href=\"https:\/\/csseditor.com\/\">The CSS<\/a> is designed to make the copy buttons visually appealing and user-friendly. Here&#8217;s the styling used:<\/p>\n<div style=\"background: #ffffff; overflow: auto; width: auto; border: solid gray; border-width: .1em .1em .1em .8em; padding: .2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #bb0066; font-weight: bold;\">.copyButton<\/span> {\n    <span style=\"color: #008800; font-weight: bold;\">display<\/span><span style=\"color: #333333;\">:<\/span> <span style=\"color: #008800; font-weight: bold;\">inline<\/span><span style=\"color: #333333;\">-<\/span><span style=\"color: #008800; font-weight: bold;\">block<\/span>;\n    <span style=\"color: #008800; font-weight: bold;\">color<\/span><span style=\"color: #333333;\">:<\/span> <span style=\"color: #6600ee; font-weight: bold;\">#FFF<\/span>;\n    <span style=\"color: #008800; font-weight: bold;\">font-weight<\/span><span style=\"color: #333333;\">:<\/span> <span style=\"color: #008800; font-weight: bold;\">bold<\/span>;\n    <span style=\"color: #008800; font-weight: bold;\">padding<\/span><span style=\"color: #333333;\">:<\/span> <span style=\"color: #6600ee; font-weight: bold;\">3px<\/span> <span style=\"color: #6600ee; font-weight: bold;\">8px<\/span>;\n    <span style=\"color: #008800; font-weight: bold;\">min-width<\/span><span style=\"color: #333333;\">:<\/span> <span style=\"color: #6600ee; font-weight: bold;\">65px<\/span>;\n    <span style=\"color: #008800; font-weight: bold;\">text-align<\/span><span style=\"color: #333333;\">:<\/span> <span style=\"color: #008800; font-weight: bold;\">left<\/span>;\n    <span style=\"color: #008800; font-weight: bold;\">margin<\/span><span style=\"color: #333333;\">:<\/span> <span style=\"color: #6600ee; font-weight: bold;\">3px<\/span> <span style=\"color: #6600ee; font-weight: bold;\">0<\/span> <span style=\"color: #6600ee; font-weight: bold;\">0<\/span>;\n    user<span style=\"color: #333333;\">-<\/span>select<span style=\"color: #333333;\">:<\/span> <span style=\"color: #008800; font-weight: bold;\">none<\/span>;\n    <span style=\"color: #008800; font-weight: bold;\">line-height<\/span><span style=\"color: #333333;\">:<\/span> <span style=\"color: #6600ee; font-weight: bold;\">18px<\/span>;\n    <span style=\"color: #008800; font-weight: bold;\">font-size<\/span><span style=\"color: #333333;\">:<\/span> <span style=\"color: #6600ee; font-weight: bold;\">16px<\/span>;\n    <span style=\"color: #008800; font-weight: bold;\">border<\/span><span style=\"color: #333333;\">-<\/span>radius<span style=\"color: #333333;\">:<\/span> <span style=\"color: #6600ee; font-weight: bold;\">7px<\/span>;\n    box<span style=\"color: #333333;\">-<\/span>shadow<span style=\"color: #333333;\">:<\/span> <span style=\"color: #6600ee; font-weight: bold;\">2px<\/span> <span style=\"color: #6600ee; font-weight: bold;\">2px<\/span> <span style=\"color: #6600ee; font-weight: bold;\">2px<\/span> <span style=\"color: #6600ee; font-weight: bold;\">#555<\/span>;\n    <span style=\"color: #008800; font-weight: bold;\">cursor<\/span><span style=\"color: #333333;\">:<\/span> <span style=\"color: #008800; font-weight: bold;\">pointer<\/span>;\n    <span style=\"color: #008800; font-weight: bold;\">background<\/span><span style=\"color: #333333;\">:<\/span> <span style=\"color: #008800; font-weight: bold;\">none<\/span> <span style=\"color: #008800; font-weight: bold;\">center<\/span> <span style=\"color: #008800; font-weight: bold;\">right<\/span> <span style=\"color: #008800; font-weight: bold;\">no-repeat<\/span> <span style=\"color: #6600ee; font-weight: bold;\">#ce5937<\/span>;\n}\n<span style=\"color: #bb0066; font-weight: bold;\">.copyButton<\/span><span style=\"color: #555555; font-weight: bold;\">:hover<\/span>{\n    <span style=\"color: #008800; font-weight: bold;\">background-color<\/span><span style=\"color: #333333;\">:<\/span><span style=\"color: #6600ee; font-weight: bold;\">#0769AD<\/span>\n}\n<span style=\"color: #007700;\">textarea<\/span><span style=\"color: #0066bb; font-weight: bold;\">#copyTextArea<\/span>{\n<span style=\"color: #008800; font-weight: bold;\">    <\/span><span style=\"color: #008800; font-weight: bold;\">opacity<\/span><span style=\"color: #333333;\">:<\/span><span style=\"color: #6600ee; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #6600ee; font-weight: bold;\">01<\/span>;\n<span style=\"color: #008800; font-weight: bold;\">    <\/span><span style=\"color: #008800; font-weight: bold;\">width<\/span><span style=\"color: #333333;\">:<\/span><span style=\"color: #6600ee; font-weight: bold;\">2px<\/span>;\n<span style=\"color: #008800; font-weight: bold;\">    <\/span><span style=\"color: #008800; font-weight: bold;\">height<\/span><span style=\"color: #333333;\">:<\/span><span style=\"color: #6600ee; font-weight: bold;\">2px<\/span>;\n}\n<\/pre>\n<\/div>\n<p>This CSS ensures the buttons are easily identifiable, with a bold font and a background color that changes on hover. The hidden textarea is styled to be practically invisible to the user.<\/p>\n<h3>Pro Tip<\/h3>\n<p>Include this background-image to add a clipboard icon to the button, just like in our demo:<\/p>\n<p><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" xmlns:xlink=\"http:\/\/www.w3.org\/1999\/xlink\" width=\"20px\" height=\"20px\" viewbox=\"0 0 20 20\" version=\"1.1\"><g><path style=\"stroke: none; fill-rule: nonzero; fill: brown; fill-opacity: 1;\" d=\"M 15.78125 2.425781 L 13.738281 2.425781 L 13.738281 2.277344 C 13.738281 1.902344 13.429688 1.59375 13.054688 1.59375 L 11.683594 1.59375 L 11.683594 0.683594 C 11.683594 0.304688 11.375 0 11 0 L 9 0 C 8.625 0 8.316406 0.304688 8.316406 0.683594 L 8.316406 1.59375 L 6.945312 1.59375 C 6.570312 1.59375 6.261719 1.902344 6.261719 2.277344 L 6.261719 2.425781 L 4.21875 2.425781 C 3.710938 2.425781 3.296875 2.839844 3.296875 3.351562 L 3.296875 19.074219 C 3.296875 19.585938 3.710938 20 4.21875 20 L 15.78125 20 C 16.289062 20 16.703125 19.585938 16.703125 19.074219 L 16.703125 3.351562 C 16.703125 2.839844 16.289062 2.425781 15.78125 2.425781 Z M 6.953125 5.398438 L 13.050781 5.398438 C 13.414062 5.398438 13.710938 5.101562 13.710938 4.738281 L 13.710938 4.007812 L 15.320312 4.007812 L 15.324219 18.535156 L 4.679688 18.539062 L 4.679688 4.007812 L 6.292969 4.007812 L 6.292969 4.738281 C 6.289062 5.101562 6.585938 5.398438 6.953125 5.398438 Z M 6.953125 5.398438 \"><\/path><\/g><\/svg><\/p>\n<p><em><strong>.copyButton<\/strong> { background-image: url(&#8220;data:image\/svg+xml,%3C%3Fxml version=&#8217;1.0&#8242; encoding=&#8217;UTF-8&#8217;%3F%3E%3Csvg fill=&#8217;red&#8217; xmlns=&#8217;http:\/\/www.w3.org\/2000\/svg&#8217; xmlns:xlink=&#8217;http:\/\/www.w3.org\/1999\/xlink&#8217; width=&#8217;20px&#8217; height=&#8217;20px&#8217; viewBox=&#8217;0 0 20 20&#8242; version=&#8217;1.1&#8217;%3E%3Cg%3E%3Cpath style=&#8217; stroke:none;fill-rule:nonzero;fill:rgb(255,255,255);fill-opacity:1;&#8217; d=&#8217;M 15.78125 2.425781 L 13.738281 2.425781 L 13.738281 2.277344 C 13.738281 1.902344 13.429688 1.59375 13.054688 1.59375 L 11.683594 1.59375 L 11.683594 0.683594 C 11.683594 0.304688 11.375 0 11 0 L 9 0 C 8.625 0 8.316406 0.304688 8.316406 0.683594 L 8.316406 1.59375 L 6.945312 1.59375 C 6.570312 1.59375 6.261719 1.902344 6.261719 2.277344 L 6.261719 2.425781 L 4.21875 2.425781 C 3.710938 2.425781 3.296875 2.839844 3.296875 3.351562 L 3.296875 19.074219 C 3.296875 19.585938 3.710938 20 4.21875 20 L 15.78125 20 C 16.289062 20 16.703125 19.585938 16.703125 19.074219 L 16.703125 3.351562 C 16.703125 2.839844 16.289062 2.425781 15.78125 2.425781 Z M 6.953125 5.398438 L 13.050781 5.398438 C 13.414062 5.398438 13.710938 5.101562 13.710938 4.738281 L 13.710938 4.007812 L 15.320312 4.007812 L 15.324219 18.535156 L 4.679688 18.539062 L 4.679688 4.007812 L 6.292969 4.007812 L 6.292969 4.738281 C 6.289062 5.101562 6.585938 5.398438 6.953125 5.398438 Z M 6.953125 5.398438 &#8216;\/%3E%3C\/g%3E%3C\/svg%3E&#8221;);}<\/em><\/p>\n<p class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2024\/06\/copy-to-clipboard-banner.jpg\" alt=\"copy to clipboard banner\" \/><\/p>\n<h3>jQuery Script<\/h3>\n<p>The jQuery script brings the &#8220;Copy to Clipboard&#8221; button to life by handling the click event and executing the copy command:<\/p>\n<div style=\"background: #ffffff; overflow: auto; width: auto; border: solid gray; border-width: .1em .1em .1em .8em; padding: .2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">var<\/span> copyBuffer;\n$(<span style=\"color: #007020;\">document<\/span>).ready(<span style=\"color: #008800; font-weight: bold;\">function<\/span>() {\n\t$(<span style=\"background-color: #fff0f0;\">\".copyButton\"<\/span>).click(<span style=\"color: #008800; font-weight: bold;\">function<\/span>() {\n\t\tcopyBuffer <span style=\"color: #333333;\">=<\/span> $(<span style=\"color: #008800; font-weight: bold;\">this<\/span>).attr(<span style=\"background-color: #fff0f0;\">\"data-target\"<\/span>);\n\t\t$(<span style=\"background-color: #fff0f0;\">\"#copyTextArea\"<\/span>).val($(copyBuffer).html());\n\t\t\n\t\t$(<span style=\"background-color: #fff0f0;\">\"#copyTextArea\"<\/span>).focus();\n\t\t$(<span style=\"background-color: #fff0f0;\">\"#copyTextArea\"<\/span>).select();\n\t\t  <span style=\"color: #008800; font-weight: bold;\">try<\/span> {\n\t\t\t<span style=\"color: #008800; font-weight: bold;\">var<\/span> successful <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">document<\/span>.execCommand(<span style=\"background-color: #fff0f0;\">'copy'<\/span>);\n\t\t\t<span style=\"color: #008800; font-weight: bold;\">var<\/span> msg <span style=\"color: #333333;\">=<\/span> successful <span style=\"color: #333333;\">?<\/span> <span style=\"background-color: #fff0f0;\">'successful'<\/span> <span style=\"color: #333333;\">:<\/span> <span style=\"background-color: #fff0f0;\">'unsuccessful'<\/span>;\n\t\t\t$(<span style=\"background-color: #fff0f0;\">\".copyButton\"<\/span>).text(<span style=\"background-color: #fff0f0;\">\"Copied\"<\/span>);\n\t\t  } <span style=\"color: #008800; font-weight: bold;\">catch<\/span> (err) {\n\t\t\t$(<span style=\"background-color: #fff0f0;\">\".copyButton\"<\/span>).text(<span style=\"background-color: #fff0f0;\">\"Error\"<\/span>);\n\t\t  }\n\t\tsetTimeout(<span style=\"color: #008800; font-weight: bold;\">function<\/span>(){ \n\t\t\t$(<span style=\"background-color: #fff0f0;\">\".copyButton\"<\/span>).text(<span style=\"background-color: #fff0f0;\">\"Copy\"<\/span>);\n\t\t}, <span style=\"color: #0000dd; font-weight: bold;\">2000<\/span>);\n\t});\n});\n<\/pre>\n<\/div>\n<h3>How It Works:<\/h3>\n<ol>\n<li><strong>Click Event<\/strong>: When the <code>copyButton<\/code> is clicked, the script retrieves the <code>data-target<\/code> attribute to identify which text element&#8217;s content should be copied.<\/li>\n<li><strong>Send it to the Textarea<\/strong>: The content of the specified text element is copied into the hidden <code>copyTextArea<\/code>.<\/li>\n<li><strong>Copy Command<\/strong>: The script focuses on the hidden textarea, selects its content, and then executes the copy command using <code>document.execCommand('copy')<\/code>.<\/li>\n<li><strong>Feedback<\/strong>: The button text changes to &#8220;Copied&#8221; for two seconds to provide feedback to the user.<\/li>\n<\/ol>\n<h3>Benefits:<\/h3>\n<ul>\n<li><strong>Simplicity<\/strong>: Users can copy text with a single click, enhancing user experience.<\/li>\n<li><strong>Visual Feedback<\/strong>: The button provides immediate visual feedback, indicating whether the copy action was successful.<\/li>\n<li><strong>Cross-Browser Compatibility<\/strong>: The approach uses widely supported web standards, ensuring compatibility across different browsers.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>A very simple solution to allow website visitors to copy website content to their clipboard\ud83d\udccb with a single click or tap. Enhance your website&#8217;s user experience adding this feature. Grab the code below or see the live demo on jsFiddle.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,2,3,4,5,6,8],"tags":[],"class_list":["post-2040","post","type-post","status-publish","format-standard","hentry","category-articles","category-css","category-freebies","category-html","category-javascript","category-jquery","category-tools"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Simple &quot;Copy to Clipboard&quot; Website Button with jQuery<\/title>\n<meta name=\"description\" content=\"A very simple solution to allow website visitors to copy website content to their clipboard with a single click or tap. Grab the code below\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Simple &quot;Copy to Clipboard&quot; Website Button with jQuery\" \/>\n<meta property=\"og:description\" content=\"A very simple solution to allow website visitors to copy website content to their clipboard with a single click or tap. Grab the code below\" \/>\n<meta property=\"og:url\" content=\"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/\" \/>\n<meta property=\"og:site_name\" content=\"HTML Online\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/htmlcoding\/\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-03T16:55:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-09T12:22:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2024\/06\/new-html-editor-feature-copy-button.jpg\" \/>\n<meta name=\"author\" content=\"HTML Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"HTML Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/\"},\"author\":{\"name\":\"HTML Editor\",\"@id\":\"https:\/\/html-online.com\/articles\/#\/schema\/person\/019f9afa07f209153df0fecfc90b8c1d\"},\"headline\":\"Simple &#8220;Copy to Clipboard&#8221; Website Button with jQuery\",\"datePublished\":\"2025-06-03T16:55:22+00:00\",\"dateModified\":\"2025-06-09T12:22:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/\"},\"wordCount\":548,\"publisher\":{\"@id\":\"https:\/\/html-online.com\/articles\/#organization\"},\"image\":{\"@id\":\"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2024\/06\/new-html-editor-feature-copy-button.jpg\",\"articleSection\":[\"Articles\",\"CSS\",\"Freebies\",\"HTML\",\"JavaScript\",\"jQuery\",\"Tools\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/\",\"url\":\"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/\",\"name\":\"Simple \\\"Copy to Clipboard\\\" Website Button with jQuery\",\"isPartOf\":{\"@id\":\"https:\/\/html-online.com\/articles\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2024\/06\/new-html-editor-feature-copy-button.jpg\",\"datePublished\":\"2025-06-03T16:55:22+00:00\",\"dateModified\":\"2025-06-09T12:22:26+00:00\",\"description\":\"A very simple solution to allow website visitors to copy website content to their clipboard with a single click or tap. Grab the code below\",\"breadcrumb\":{\"@id\":\"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/#primaryimage\",\"url\":\"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2024\/06\/new-html-editor-feature-copy-button.jpg\",\"contentUrl\":\"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2024\/06\/new-html-editor-feature-copy-button.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/html-online.com\/articles\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Simple &#8220;Copy to Clipboard&#8221; Website Button with jQuery\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/html-online.com\/articles\/#website\",\"url\":\"https:\/\/html-online.com\/articles\/\",\"name\":\"HTML Online Articles\",\"description\":\"Tips, tricks, tutorials\u2026\",\"publisher\":{\"@id\":\"https:\/\/html-online.com\/articles\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/html-online.com\/articles\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/html-online.com\/articles\/#organization\",\"name\":\"HTML Online\",\"url\":\"https:\/\/html-online.com\/articles\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/html-online.com\/articles\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2022\/06\/logo.jpg\",\"contentUrl\":\"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2022\/06\/logo.jpg\",\"width\":350,\"height\":350,\"caption\":\"HTML Online\"},\"image\":{\"@id\":\"https:\/\/html-online.com\/articles\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/htmlcoding\/\",\"https:\/\/www.linkedin.com\/in\/ferencdenes\/\",\"https:\/\/www.youtube.com\/channel\/UCn38Jw1sJzbjVHO95Zp0Sww\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/html-online.com\/articles\/#\/schema\/person\/019f9afa07f209153df0fecfc90b8c1d\",\"name\":\"HTML Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/html-online.com\/articles\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/7c1d8f5e7f1dc3e261766a96ac50c6a907fa5c236e87ab73379c57c9114e92cd?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/7c1d8f5e7f1dc3e261766a96ac50c6a907fa5c236e87ab73379c57c9114e92cd?s=96&d=mm&r=g\",\"caption\":\"HTML Editor\"},\"description\":\"In 2013, while wrestling with a mountain of client articles and an uncooperative CMS, I decided enough was enough. So, I created an online HTML editor purely out of necessity (and mild frustration). What began as a tool for my own sanity quickly evolved into a gift for the world\u2014or at least for anyone trying to avoid breaking their website's code. Since then, I've shared my tech notes on my blog, which serves as both a handy reference and a digital diary of the adventures and misadventures of a coder.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/ferencdenes\/\",\"https:\/\/www.youtube.com\/@htmlg\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Simple \"Copy to Clipboard\" Website Button with jQuery","description":"A very simple solution to allow website visitors to copy website content to their clipboard with a single click or tap. Grab the code below","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/","og_locale":"en_GB","og_type":"article","og_title":"Simple \"Copy to Clipboard\" Website Button with jQuery","og_description":"A very simple solution to allow website visitors to copy website content to their clipboard with a single click or tap. Grab the code below","og_url":"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/","og_site_name":"HTML Online","article_publisher":"https:\/\/www.facebook.com\/htmlcoding\/","article_published_time":"2025-06-03T16:55:22+00:00","article_modified_time":"2025-06-09T12:22:26+00:00","og_image":[{"url":"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2024\/06\/new-html-editor-feature-copy-button.jpg","type":"","width":"","height":""}],"author":"HTML Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"HTML Editor","Estimated reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/#article","isPartOf":{"@id":"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/"},"author":{"name":"HTML Editor","@id":"https:\/\/html-online.com\/articles\/#\/schema\/person\/019f9afa07f209153df0fecfc90b8c1d"},"headline":"Simple &#8220;Copy to Clipboard&#8221; Website Button with jQuery","datePublished":"2025-06-03T16:55:22+00:00","dateModified":"2025-06-09T12:22:26+00:00","mainEntityOfPage":{"@id":"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/"},"wordCount":548,"publisher":{"@id":"https:\/\/html-online.com\/articles\/#organization"},"image":{"@id":"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/#primaryimage"},"thumbnailUrl":"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2024\/06\/new-html-editor-feature-copy-button.jpg","articleSection":["Articles","CSS","Freebies","HTML","JavaScript","jQuery","Tools"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/","url":"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/","name":"Simple \"Copy to Clipboard\" Website Button with jQuery","isPartOf":{"@id":"https:\/\/html-online.com\/articles\/#website"},"primaryImageOfPage":{"@id":"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/#primaryimage"},"image":{"@id":"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/#primaryimage"},"thumbnailUrl":"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2024\/06\/new-html-editor-feature-copy-button.jpg","datePublished":"2025-06-03T16:55:22+00:00","dateModified":"2025-06-09T12:22:26+00:00","description":"A very simple solution to allow website visitors to copy website content to their clipboard with a single click or tap. Grab the code below","breadcrumb":{"@id":"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/#primaryimage","url":"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2024\/06\/new-html-editor-feature-copy-button.jpg","contentUrl":"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2024\/06\/new-html-editor-feature-copy-button.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/html-online.com\/articles\/copy-to-clipboard-website-button-jquery\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/html-online.com\/articles\/"},{"@type":"ListItem","position":2,"name":"Simple &#8220;Copy to Clipboard&#8221; Website Button with jQuery"}]},{"@type":"WebSite","@id":"https:\/\/html-online.com\/articles\/#website","url":"https:\/\/html-online.com\/articles\/","name":"HTML Online Articles","description":"Tips, tricks, tutorials\u2026","publisher":{"@id":"https:\/\/html-online.com\/articles\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/html-online.com\/articles\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/html-online.com\/articles\/#organization","name":"HTML Online","url":"https:\/\/html-online.com\/articles\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/html-online.com\/articles\/#\/schema\/logo\/image\/","url":"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2022\/06\/logo.jpg","contentUrl":"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2022\/06\/logo.jpg","width":350,"height":350,"caption":"HTML Online"},"image":{"@id":"https:\/\/html-online.com\/articles\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/htmlcoding\/","https:\/\/www.linkedin.com\/in\/ferencdenes\/","https:\/\/www.youtube.com\/channel\/UCn38Jw1sJzbjVHO95Zp0Sww"]},{"@type":"Person","@id":"https:\/\/html-online.com\/articles\/#\/schema\/person\/019f9afa07f209153df0fecfc90b8c1d","name":"HTML Editor","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/html-online.com\/articles\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/7c1d8f5e7f1dc3e261766a96ac50c6a907fa5c236e87ab73379c57c9114e92cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7c1d8f5e7f1dc3e261766a96ac50c6a907fa5c236e87ab73379c57c9114e92cd?s=96&d=mm&r=g","caption":"HTML Editor"},"description":"In 2013, while wrestling with a mountain of client articles and an uncooperative CMS, I decided enough was enough. So, I created an online HTML editor purely out of necessity (and mild frustration). What began as a tool for my own sanity quickly evolved into a gift for the world\u2014or at least for anyone trying to avoid breaking their website's code. Since then, I've shared my tech notes on my blog, which serves as both a handy reference and a digital diary of the adventures and misadventures of a coder.","sameAs":["https:\/\/www.linkedin.com\/in\/ferencdenes\/","https:\/\/www.youtube.com\/@htmlg"]}]}},"_links":{"self":[{"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/posts\/2040","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/comments?post=2040"}],"version-history":[{"count":2,"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/posts\/2040\/revisions"}],"predecessor-version":[{"id":2043,"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/posts\/2040\/revisions\/2043"}],"wp:attachment":[{"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/media?parent=2040"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/categories?post=2040"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/tags?post=2040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}