Reputation: 57
I am trying to create add to calendar link/button. When i click at button/ link it will give me an option of google calendar/outlook calendar/ yahoo calendar etc. Here is a snip that I am trying to add in my file.
I got this from https://www.addevent.com/
Anyone has an idea about it? Thank You!
Upvotes: 0
Views: 6510
Reputation: 1876
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
// Close the dropdown if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
.dropbtn {
background-color: white;
border: 1px solid #777;
color: #4c4c4c;
padding: 16px;
font-size: 16px;
cursor: pointer;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #fff;
border: 1px solid lightgray;
min-width: 200px;
overflow: auto;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
color:#4c4c4c;
}
.dropdown a:hover {background-color: #ddd;}
.show {display: block;}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn"> <i class="fa fa-calendar-o" aria-hidden="true"></i> Add to Calendar</button>
<div id="myDropdown" class="dropdown-content">
<a href="#"> <i class="fa fa-apple" aria-hidden="true"></i> Apple calendar</a>
<a href="#"> <i class="fa fa-google" aria-hidden="true"></i> Google</a>
<a href="#"> <i class="fa fa-windows" aria-hidden="true"></i> Outlook</a>
<a href="#"><i class="fa fa-yahoo" aria-hidden="true"></i> Yahoo</a>
</div>
</div>
Upvotes: 4