JSFiddle - React, Tailwind, and code Playground

by Lucas Krause

HTML

<p><input type="text" /><input type="checkbox" /><textarea></textarea><select><option>1</option><option>2</option><option>3</option></select><button></button></p>

<hr />
<blockquote>Note: For performance reasons, the dynamic state of certain form elements (e.g., user data typed into textarea and user selections made to a select) is not copied to the cloned elements. When cloning input elements, the dynamic state of the element (e.g., user data typed into text inputs and user selections made to a checkbox) is retained in the cloned elements.<br />&mdash; <a href="http://api.jquery.com/clone/">jQuery documentation .clone()</a></blockquote>

JavaScript

$("[type=checkbox]").prop("checked", true);
$("[type=text]").val("hallo");
$("textarea").val("hallo");
$("option:last-child").prop("selected", true);
$("button").val("1, 2, 3");

var a=$("p").clone(!true).insertAfter($("p"));

console.log($("button", a).val());