Oops, sorry, delete this line in my code:
alert($(sClass).text());
This works perfectly. Thank you very much.
I had to make some small changes to button because it wouldn't work trying to add it to the Title field. <button onclick="print_elem('.bx-base-profile-entity-content');">Print me!</button>