I have the following code to share my website through some social networks when the user clicks some divs with the appropriate icons.
var loc = encodeURIComponent(document.location.href);
$(document).ready(function() {
$("#shareFacebook").click(function() {
window.open('https://www.facebook.com/sharer/sharer.php?u=' + loc, '_blank');
});
$("#shareTwitter").click(function() {
window.open('https://twitter.com/share?url=' + loc + '&text=myText', '_blank');
});
$("#shareGooglePlus").click(function() {
window.open('https://plus.google.com/share?url=' + loc, '_blank');
});
$("#shareLinkedIn").click(function() {
window.open('https://www.linkedin.com/shareArticle?mini=true&url=' + loc + '&title=mySite&summary=myText', '_blank');
});
$("#sharePinterest").click(function() {
window.open('https://pinterest.com/pin/create/button/?url=http://mysite.com/logo.png&media=Logo&description=myText', '_blank');
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="shareFacebook">
<div class="icon-facebook"></div><span>Facebook</span>
</div>
<div id="shareTwitter">
<div class="icon-twitter"></div><span>Twitter</span>
</div>
<div id="shareGooglePlus">
<div class="icon-google-plus"></div><span>Google+</span>
</div>
<div id="shareLinkedIn">
<div class="icon-linkedin"></div><span>LinkedIn</span>
</div>
<div id="sharePinterest">
<div class="icon-pinterest"></div><span>Pinterest</span>
</div>
(Even if the code works, for some reason, the snippet does not.)
Can it be made more efficient?