JSFiddle - React, Tailwind, and code Playground

by Chan Wu

HTML

<form>
    <input type="text" name="title"><br>
    <textarea  name="content"></textarea>
</form>
<a href="#" onclick="window.location.reload(); return false;">重新整理</a>

JavaScript

var isChange = false;

$('select, input, textarea').on('change', function() {
    isChange = true;
});

$(window).on('beforeunload', function() {
    if (true === isChange) {
        return '您已經修改過內容,確定要離開嗎?';
    }
})