How it works…

The core of this recipe can be found in _recipe-07-02-js.ejs. This code is relatively complex if you are new to it; thus, to make sure that we have the correct code, let's list the completed file after all the steps that pertain to it are inserted as described:

<script>// the plugin itself(function ($) { $.fn.canYouFindIt2 = function( options ) { var defaults = $.extend({ cssProperty: 'background-color', cssValue: 'lightsalmon' }, options); return this.each(function (i, elem) {  var $currentIndex = $(elem); $currentIndex.css(defaults.cssProperty, defaults.cssValue); }); }; })(jQuery);// calling the plugin $('a').canYouFindIt2({ cssValue: 'yellow'});</script>

There are quite a few things happening here, so let's go through ...

Get Bootstrap 4 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.