(function ($) { //create closure so we can safely use $ as alias for jQuery $(document).ready(function () { // initialise plugin var example = $('#example').superfish({ //add options here if required }); // buttons to demonstrate Superfish's public methods $('.destroy').on('click', function () { example.superfish('destroy'); }); $('.init').on('click', function () { example.superfish(); }); $('.open').on('click', function () { example.children('li:first').superfish('show'); }); $('.close').on('click', function () { example.children('li:first').superfish('hide'); }); }); })(jQuery);