When I use embedded javascript functions I can get client id of elements with this code:
document.getElementById(\'<%=buttonXXX
I use the following code in my .js file, when I have no other better choice.
.js
$("[id$='buttonXXX'])