Не изменяется цвет при вызове функции
Пишу плагин с анимацией, но не зная тонкости яваскрипта столкнулся с проблемкой. Не хочет передаваться цвет при вызове функции. Собственно код.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script> (function ($) { $.fn.colorFoo = function () { return this.each(function (options) { var settings = $.extend({ bordColor : 'green' },options||{}); $(this).css('color', settings.bordColor); }); } })(jQuery); $(function () { $('.color').colorFoo({ bordColor: 'red' }); }); </script> </head> <body> <p class="color">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nulla, fugit.</p> </body> </html> |
hhh,
аргумент не туда передаете options <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script> (function ($) { $.fn.colorFoo = function (options) { return this.each(function () { var settings = $.extend({ bordColor : 'green' },options||{}); $(this).css('color', settings.bordColor); }); } })(jQuery); $(function () { $('.color').colorFoo({ bordColor: 'red' }); }); </script> </head> <body> <p class="color">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nulla, fugit.</p> </body> </html> |
Спасибо! Как обычно, ржу с себя.:D
|
hhh,
)) |
Часовой пояс GMT +3, время: 09:52. |