jQuery - conditional variable

0 votes
144 views
added Jun 10, 2021 in jQuery by lcjr First Warrant Officer (11,890 points)
$('#whatsapptep').click(function(){
    var whatsAppPhone = '60173686061';   
    var defaultMessage = "";
    var url = window.location.href;
    if(url.includes('1860554')) {
      defaultMessage = "Hi, I'm interested to know more about this product:";
    }  else {
      defaultMessage = "Hi, I'm interested to know more about this project:";
    } 
    window.open(
      "https://wa.me/"+whatsAppPhone+"?text="+defaultMessage+" "+window.location.href,
      '_blank',
    );
});

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...