jQuery alternative for slice call argument
Is there a cleaner way to do this using jQuery? I had a solution worked out to display the dynamic phone number, which is based on the URL string, using the id, but then realized the phone number could possibly appear in multiple places on the page.
- $(document).ready(function(){
- var tfn = QueryString.tfn;
- if(tfn == '1111')
- phoneVar = '800.555.1111'
- else if(tfn == '2222')
- phoneVar = '800.555.2222'
- else if(tfn == '3333')
- phoneVar = '800.555.3333'
- else
- phoneVar = '800.555.0000'
-
- document.getElementById('phNumber').innerHTML = phoneVar;
-
- var phClass = document.getElementById( 'phNumber' ),
- phDivs = document.getElementsByClassName( 'phNumberC' );
-
- [].slice.call( phDivs ).forEach(function ( div ) {
- div.innerHTML = phClass.innerHTML;
- });
-
- phoneLink = "tel:" + phoneVar
- $('a.phLink').attr('href', phoneLink);
- });
- <a class="phLink" href=""><span id="phNumber"></span></a>
- <a class="phLink" href=""><span class="phNumberC"></span></a>