<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<title>Link Preview</title>
<style>
.custom-div {
width: 200px;
height: 100px;
background-color: lightblue;
text-align: center;
line-height: 100px;
cursor: pointer;
}
.link-preview {
position: fixed;
bottom: 0;
left: 0;
width: 200px;
background-color: #f0f0f0;
border-top-right-radius: 5px;
border-top: 1px solid #ccc;
display: none;
padding: 5px;
}
.link-preview a {
color: blue;
text-decoration: underline;
}
</style>
</head>
<body>
<div class=”custom-div”>
Coba Simpan Kursor Disini
</div>
<div class=”link-preview” id=”linkPreview”>
<a href=”#” id=”previewLink”></a>
</div>
<script>
const customDiv = document.querySelector(‘.custom-div’);
const linkPreview = document.querySelector(‘.link-preview’);
const previewLink = document.getElementById(‘previewLink’);
customDiv.addEventListener(‘mouseover’, (event) => {
if (event.target === customDiv) {
linkPreview.style.display = ‘block’;
previewLink.textContent = ‘https://www.example.com’;
previewLink.href = ‘https://www.example.com’;
}
});
customDiv.addEventListener(‘mouseout’, () => {
linkPreview.style.display = ‘none’;
});
</script>
</body>
</html>