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