O'Reilly logo

Bootstrap 4 Cookbook by Ajdin Imsirovic

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required