jQuery plugin example

by Niki Molnar

HTML

<div id="here">
</div>
<script>
$(document).ready(function() {$("#here").hello({name: "Jane Doe"})})</script>

CSS

body {
  background: #fff;
  padding: 20px;
  font-family: Helvetica;
}}

JavaScript

(function ( $ ) {
 
    $.fn.hello = function( options ) {
 
        // Default options
        var settings = $.extend({
            name: 'John Doe'
        }, options );
 
        // Apply options
        return this.append('Hello ' + settings.name + '!');
 
    };
 
}( jQuery ));