How to do it…

  1. Open the currently blank _recipe07-02-js.ejs and paste the following code:
<script>// the plugin itself(function ($) { $.fn.canYouFindIt2 = function() { return this.css("background-color", "lightsalmon"); }})(jQuery);// calling the plugin $('a').canYouFindIt2();</script>
  1. Let's abstract away the hardcoded values using the extend() method and passing in the options object:
$.fn.canYouFindIt2 = function( options ) {  var defaults = $.extend({    cssProperty: 'background-color',    cssValue: 'lightsalmon'  }, options);  // step 3 will be added here}
  1. Find the commented line that reads step 3 will be added here, and in its place, add the following code:
return this.each(function(i, elem) {  var $currentIndex = $(elem); $currentIndex.css(defaults.cssProperty, ...

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.