navigator.clipboard.writeText('the text')
<input type="text" placeholder="Create Password" id="text" readonly>
<script>
function copyPassword(){
var copyText = document.getElementById('text')
copyText.select()
copyText.setSelectionRange(0, 999)
document.execCommand("copy")
console.log(copyText);
}
</script>
function copyToClipboard(element) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val($(element).text()).select();
document.execCommand("copy");
$temp.remove();
}
var $inp = $(".passInput");
$inp.on({
input: function(ev) {
if(this.value) {
$inp.eq($inp.index(this) + 1).focus();
}
},
keydown: function(ev) {
var i = $inp.index(this);
if(ev.which===8 && !this.value && i) {
$inp.eq(i - 1).focus();
}
},
paste: function(e) {
var pastedData = e.originalEvent.clipboardData.getData('text');
var pastedChars = pastedData.split("");
var curIndex = $inp.index(this)
for (var i=0; i < pastedChars.length; i++) {
var char = pastedChars[i]
$inp.eq(curIndex + i).val(char).focus();
}
}
});