Skip to content

Commit d591e4b

Browse files
Improve copyText function with alerts
Enhance copyText function to show success or failure alerts
1 parent 01162a5 commit d591e4b

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
<img src="photoofme.jpeg" alt="Profile photo" class="avatar">
1515
<button class="cta-button" onclick="copyText()">Copy Email</button>
1616
<script>
17-
function copyText() {
18-
navigator.clipboard.writeText("r0hanmodi11111@gmail.com");
19-
}
17+
function copyText() {
18+
navigator.clipboard.writeText("r0hanmodi11111@gmail.com")
19+
.then(() => alert("Email copied!"))
20+
.catch(() => alert("Failed to copy."));
21+
}
2022
</script>
2123
<h1>Rohan Modi</h1>
2224
<p class="subtitleiguess">High School Student • Developer</p>

0 commit comments

Comments
 (0)