特定のdivをクリックしてクリップボードにコピーしたいのですが、インターネット上で3日間検索しても何も機能していません。例がある場合は、HEREに行ってください。私は、16進コードをクリックしてクリップボードにコピーしたい、誰かが私を助けることができますか?ブラウザでクリップボードへHTMLとJSでコピーボタンを作る
<html>
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Quicksand" />
<head>
<style>
#text {
width: 100%;
height: 700px;
text-align: center;
font-size: 50px;
font-family: 'Quicksand';
}
body {
text-align: center;
font-family: 'Quicksand';
margin-top: 0px;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
}
</style>
</head>
<body>
<h1>Rainbow Hover</h1>
<h2><strong>Hover over the rainbow to get a random color!</strong></h2>
<div id="text"></div>
<script type="text/javascript">
var div = document.getElementById('text'),
randomColor = function(e) {
var hex = Math.floor(Math.random() * 0xFFFFFF),
res = e.target,
result = "#" + hex.toString(16);
res.style.backgroundColor = result;
res.innerHTML = result;
};
div.addEventListener('mouseover', randomColor);
</script>
</body>
</html>
あなたの質問に関連するソースコードが含まれ、あなたがしようとしているかを説明してください。 – NewToJS
OK。私はそれを行う/ –
(https://clipboardjs.com/) –