599644 599644 - 9 months ago 34
jQuery Question

jQuery & boostrap: What does fn[NAME] do?

I am going through the javascript code for bootstrap.

In modal.js I see:

$.fn[NAME] = Modal._jQueryInterface
$.fn[NAME].Constructor = Modal


Where
NAME
is
'modal'

What does
$.fn[NAME]
do? I know what plain
$.fn
is, not sure about the
[NAME]
and thee
.Contractor
.

Answer Source

It is same as doing $.fn.modal = Modal._jQueryInterface but using [] notation instead of dot notation

Creates a plugin function to allow you to do $(selector).modal()