Simple jQuery Plugin with Callbacks

https://learn.jquery.com/plugins/advanced-plugin-concepts/

HTML

<table id="aTable">
    <tr>
        <td>a</td>
        <td>table</td>
    </tr>
</table>
<p>not a table</p>
<table id="anotherTable">
    <tr>
        <td>click</td>
        <td>me</td>
    </tr>
</table>
 <h5>not a table</h5>

CSS

table { border: 1px solid #eee; }
td { padding: 1em; border: 1px solid #eee; }

JavaScript

(function ($) {
    $.fn.copyClick = function (options) {
        var defaults = {
            onClick: function() {},
            onHover: function() {}
        };
        
        var settings = $.extend({}, defaults, options);

        this.filter("table").each(function () {
            var $table = $(this);                        
            
            $table
                .on('click', function() {
                    var $lastRow = $table.find('tr').last();
                    var $clonedRow = $lastRow.clone();
                    $table.append($clonedRow);
                    
                    onClickCallback();
                })
                .on('hover', onHoverCallback);
        });
        
        function onClickCallback() {
            settings.onClick.call();
        }
        
        function onHoverCallback() {
            settings.onHover.call();
        }

        return this;
    };
}(jQuery));

$('table#anotherTable').copyClick({
    onClick: function() {
        console.debug('copyClick.click', this);
    }
});