Jquery Widget creation

In notebook:
FrontEndMasters Advanced JS fundamentals
Created at:
pattern Fundamentals JavaScript jQuery libraries
Learn JS Fundamentals to jQuery & Pure DOM Scripting Building a Tabs Widgetthe way to add a widget is:
  $.fn.mywidget = function() {
    // ...
// then you can do is
what it does is ​$.init.prototype.mywidget = function (){}​ a more complete example:

function helperfunc (anelement) {
    // ...

$.fn.mywidget = function () {
    $.each(this, function(i, element){
        var $element = $([element]);
        // then for example
        $.each($element.children(), function(i, li){
            // ... do more stuff


​return false;vs ​e.stopPropagation​(); e.preventDefault();​​ 
​return false;​ is less explicit, less clear better use the stopPropagation and preventDefault

also if there's an error in your code before ​return false​ then it default behaviour will happen (e.g. redirecting the page)

in native javascript ​return false;​ will only do preventDefault but will not stop the propagation. In jQuery delegation it will do both.