In my code, I am trying to copy iframe code using copy to clipboard button but I am not satisfied with it because when I copy using button it copies <
and >
instead of <
and >
secondly it won't highlights the text area so is there any alternate solution to copy as HTML code thanks
Here is my JSfiddle
Here is a sample copied text
<iframe src='http://localhost/secvideo/cms/watch?v=30Rt9r' frameborder='0' style='overflow: hidden; position: absolute;' height='100%' width='100%'></iframe>
and Here is my JS
function copyToClipboard(elementId) {
var aux = document.createElement("input");
// Assign it the value of the specified element
aux.setAttribute("value", document.getElementById(elementId).innerHTML);
document.body.appendChild(aux);
aux.select();
document.execCommand("copy");
document.body.removeChild(aux);
alert("Copied!");
}