JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="test1"/>
<textarea id="test2"></textarea>
JavaScript
// Rough plugin code
var text = jQuery.fn.text;
jQuery.fn.text = function( val ) {
var self = this;
if ( val != null ) {
return this.each(function() {
if ( "value" in this ) {
this.value = val;
} else {
text.call( self, val );
}
});
}
return text.call( self );
};
// Example
jQuery("#test1").text( "Hello" );
jQuery("#test2").text( "Hello" );