Your Plug-in

by Ivan Gerasimenko

HTML

<div id="first">first</div>
<div id="second">second</div>

JavaScript

(function( $ ){
    $.fn.someFunction = function(obj) {

        this.append(obj.text);

    };
})( jQuery );

var data = {text: " new text"};

$("#first").someFunction(data);

//============ EXISTS =============
(function( $ ){
    $.fn.exists = function(obj) {
        return (this.length > 0);
    };
})( jQuery );

console.log("second exists = " + $("#second").exists());
console.log("third  exists = " + $("#third").exists());