Here are two JavaScripts. There is also a notification script.
I want to combine two javascripts in one and have both javascripts show the same notification.
This is the two different javascripts with the same notification.
<script>
function copy(that){
var text = that.textContent;
var input = document.getElementById('cb');
input.value = input.value + text +'n';
var inp =document.createElement('input');
document.body.appendChild(inp)
inp.value =that.textContent
inp.select();
document.execCommand('copy',false);
var notification = document.getElementById('symc');
notification.style.display = 'block';
setTimeout(() => {
notification.style.display = 'none';
}, 1000);
}
</script>
<script>
function co() {
var input = document.getElementById("cb");
navigator.clipboard.writeText(input.value);
var notification = document.getElementById('symc');
notification.style.display = 'block';
setTimeout(() => {
notification.style.display = 'none';
}, 1000);
}
</script>
<span id="symc">Copied</span>
<div id="ca">
<input id="cb">
<button onclick="co()">Copy</button>
</div>
This is the notification script
var notification = document.getElementById('symc');
notification.style.display = 'block';
setTimeout(() => {
notification.style.display = 'none';
}, 1000);
Please help me how can I mix two script in one js area…
<script>
</script>
Thanks.