Skip to content

Instantly share code, notes, and snippets.

@ciaranmahoney
Last active March 9, 2018 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ciaranmahoney/d568e010e0b424ac90e7 to your computer and use it in GitHub Desktop.
Save ciaranmahoney/d568e010e0b424ac90e7 to your computer and use it in GitHub Desktop.
Click to Show Full Phone Numer - Jquery
<span id="clickToShow">xxx-xxx-xxxx</span>
<script>
var shortNumber = $("#clickToShow").text().substring(0, $("#clickToShow").text().length - 5);
var onClickInfo = "_gaq.push(['_trackEvent', 'EVENT-CATEGORY', 'EVENT-ACTION', 'EVENT-LABEL', VALUE, NON-INTERACTION]);";
$("#clickToShow").hide().after('<button id="clickToShowButton" onClick="' + onClickInfo + '">' + shortNumber + '... (click for full phone number)</button>');
$("#clickToShowButton").click(function() {
$("#clickToShow").show();
$("#clickToShowButton").hide();
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment