victorpaolo
(Victor Paolo Reategui Muriano)
May 19, 2022, 6:32pm
1
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.
<script>
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;
</script>
Here the project:
https://preview.webflow.com/preview/2sami?utm_medium=preview_link&utm_source=designer&utm_content=2sami&preview=fe421a26feb7a834eca6c9ae79b44de2&pageId=627cd36ad95f1017d0b1ccb7&itemId=627cd386b7eff821181b1120&workflow=preview
Thanks!!
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!
victorpaolo
(Victor Paolo Reategui Muriano)
May 20, 2022, 6:21am
3
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
Thanks!