Skip to content

Instantly share code, notes, and snippets.

@laminr
Created October 5, 2020 18:32
Show Gist options
  • Select an option

  • Save laminr/82588b6fdad067dec4a890590bfa5acb to your computer and use it in GitHub Desktop.

Select an option

Save laminr/82588b6fdad067dec4a890590bfa5acb to your computer and use it in GitHub Desktop.
Setting email and phone in Html tags
// <span data-email="contact"></span>
(function ($, domain) {
// updating email when needed
const elements = $("span[data-email]");
$.each(elements, function (key, value) {
var email = $(value).data('email');
value.innerHTML = email + "@" + domain;
});
// updating email when needed
const phones = $("a[data-phone]");
$.each(phones, function (key, value) {
var number = $(value).data('phone');
value.setAttribute('href', 'tel:+33 ' + number);
value.innerHTML = "+33 (0) " + number;
});
})(jQuery, "<domain>.com");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment