Created
October 5, 2020 18:32
-
-
Save laminr/82588b6fdad067dec4a890590bfa5acb to your computer and use it in GitHub Desktop.
Setting email and phone in Html tags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // <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