Whatsapp link and CMS items

Hi community!

I am trying to use button and/or text link to jump into a Whatsapp message.
I tried:

  • getElementById → ID

  • querySelector → Class

But unfortunately did not work.

const number = "34"+"Number";
const name = "Name";
const root_url = "https://wa.me/";
const custom_url = root_url+number+"?text=Hola%20"+name+",%20prueba."

document.getElementById('.whatsapp2').innerHTML = custom_url;
document.getElementById('.whatsapp3').innerHTML = custom_url;


Here the project:


Hello @victorpaolo, if you are using an element’s id then you have to use a “#” instead of a “.” On your code instead of document.getElementById(‘.whatsapp2’) you should have document.getElementById(‘#whatsapp2’). I hope this helps!

Thanks @Pablo_Cortes !

Unfortunately, I did not work.
What I did is the following and works:

  • Just delete the “.” and “#”
  • Add “.href” in the getElementById