JQuery on click with selector / data

Trying to understand the following syntax in my autocomplete plugin

    // Listen for click event on suggestions list:
    container.on('click.autocomplete', suggestionSelector, function () {



"click.autocomplete" I'm confused, there is no autocomplete class on this page, but it still works. what does ".autocomplete" mean here?


source to share

1 answer


there is no selector here, it's a namespace. The selector is contained in your variable suggestionSelector

. Handled an event click

in the namespace autocomplete


See jQuery event.namespace

and Custom Events documentation.

JQuery documentation page for its methodon()


.on( events [, selector ] [, data ], handler )


Type: String
One or more event types, separated by spaces, and optional namespaces such as "click" or "keydown.myPlugin".



All Articles