JSFiddle - React, Tailwind, and code Playground
by KyleMuir
HTML
<button data-target="hello">Click to make the input disappear</button>
<input id="hello">
JavaScript
$('button').click(function () {
// uses the button's "data-target" attribute to identify another element to toggle
var target = $('#' + $(this).data('target'));
// toggles the visibility of the target
if (target.is(':visible')) {
target.slideUp();
} else {
target.slideDown();
}
// says goodbye if it was hidden
if (target.is(':hidden')) {
alert('goodbye, cruel world!');
}
});