JSFiddle - React, Tailwind, and code Playground
by Avi Algaly
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<h3>Whatsapp sharing</h3>
<input class="mobileShow"
type="text" name="message">
<button onclick="share()" class="mobileShow">
Share to whatsapp
</button>
CSS
/* To show on small size screen only */
@media screen and (min-width: 500px) {
.mobileShow {
}
}
JavaScript
// Function to share on whatsapp
function share() {
// Getting user input
var message = $("input[name=message]").val();
// Opening URL
window.open(
"whatsapp://send?text=" + message,
// This is what makes it
// open in a new window.
'_blank'
);
}