Custom button in list view - how to get selected rows in custom function?

Custom button in list view - how to get selected rows in custom function?

I want to create a custom button in the contact list view. The user will be select one or more contacts and take action through custom button.

I would like to know how to get selected rows in the custom function associated with the the button.