Since web spiders are (still) without Javascript, there is an obvious difference between the two bits of code, it can be followed by a bot (and someone else), and the other only works for users with Javascript enabled (like that, not Google). For spiders, this should be nothing more than a div, and any URL that you set using onclick will not execute (and therefore will not be indexed from this page).