You can pass the "SelectedRecordIds" or something similar to the JavaScript function as a parameter, which is an array of all the selected contact ID's.
http://andreaswijayablog.blogspot.co.nz/2011/07/crm-2011-custom-button-on-custom-entity.html
Once you have the ID's, you can trigger a workflow using JavaScript for each selected contact, the workflow can set a hidden field on the contact, which the plugin triggers onchange of to perform your logic.
Alternatively you could skip the workflow step and update the hidden field on the contacts directly using REST JavaScript.
Hope that helps
Paul
If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".
