JSFiddle - React, Tailwind, and code Playground

by antouank

HTML

<body>
    <div id="edit">edit</div>
    <div id="value">val</div>
</body>

JavaScript

$.valHooks['myedit'] = {
    get: function (el) {
        return $(el).html();
    },
    set: function (el, val) {
        $(el).html(val);
    }
};

$.fn.myedit = function () {
    this.each(function () {
        this.type = 'myedit';
    });
    return this;
}

$('#edit').myedit().val(' Hi there!');
$('#value').html('The value is : ' + $('#edit').val());