Work with legacy and simple sites using jQuery selectors, events, AJAX, effects, and plugins.
Lessons
Extend $.fn with your own reusable method.
Writing a jQuery Plugin is easiest to learn by reading the example, changing it, and observing the result.
// Define a reusable plugin on $.fn
$.fn.highlight = function (options) {
const settings = $.extend({ color: 'yellow' }, options);
return this.each(function () {
$(this).css('background-color', settings.color);
});
};
// Use it like any built-in method (chainable)
$('.note').highlight({ color: '#fff3cd' });Practice the Writing a jQuery Plugin example in a small scratch file, then explain what changed and why.