diff --git a/js/copyColor.js b/js/copyColor.js index 65e9b0b..6416eaa 100644 --- a/js/copyColor.js +++ b/js/copyColor.js @@ -1,27 +1,23 @@ $(document).ready(function() { $('.color-box').click(function() { - //Temp. input to copy color to clip Board - let temp1 = $(""); - $("body").append(temp1); - temp1.val($(this).text().trim()).select(); - document.execCommand("copy"); - temp1.remove(); + //Temp. input to copy color to clip Board + if($(this).find('.hex-number').text() !== 'Copied!') { + let temp1 = $(""); + $("body").append(temp1); + temp1.val($(this).find('.hex-number').text()).select(); + document.execCommand("copy"); + temp1.remove(); + } - //Temp.

for displaying "color copied !" - let temp2 = $("

"); - temp2.css({ - "font-weight": "bold", - "position": "absolute", - "top": "10px", - "left": "50%", - "transform": "translateX(-50%)" - }) - $(this).append(temp2); - temp2.html('Color Copied !'); - temp2.fadeIn().delay(1000).fadeOut(); + //Changing hexNumber to "Copied!" + let hexNumber; + if($(this).find('.hex-number').text() !== 'Copied!') { + hexNumber = $(this).find('.hex-number').text(); + } + $(this).find('.hex-number').text('Copied!'); setTimeout(() => { - temp2.remove(); + $(this).find('.hex-number').text(hexNumber); }, 1000); }); });