title: How to write a jQuery widget to add 'Hello world' to the selected div
body: <p>I need some help writing a jQuery widget.</p>
  
  <p>As an exercise, I am trying to create a widget which adds a 'Hello World' message to the selected element when the page is loaded. </p>
  
  <p>The below code should append "Hello World" to div with class "123", but nothing happens. Can anyone see what I did wrong?</p>
  
  <p><strong>jQuery/javascript:</strong></p>
  
  <pre><code>$.widget("custom.hwLoader",{
  
      options: { 
      clear:null
      },
  
      _create: function() {
          this.element;
          this.name; 
          this.namespace; 
          this.element.on("load"+this.eventNamespace,
              function(){
                  $("&lt;h1&gt;Hello World&lt;/h1&gt;").appendTo(this.element);
              }
          )
      },
  
      _setOption: function( key, value ) {
  
          this._super("_setOption", key, value );
      },
  
      _destroy: function() {
          this.element.unbind('.'+this.eventNamespace);
      }
  
  });
  </code></pre>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>$("&lt;div  class='addHere'&gt;&lt;/div&gt;").appendTo("body");
  $(".addHere").hwLoader();
  </code></pre>