I found that in Google+ Project’s page that buttons are all made from divs like:
<div role="button"></div>
I’d like to know, is this just for semantic purposes, or does it influence the style or event handling of the <div>?
I tried to simulate a button "click" with the jQuery click event, but it didn’t work.
It tells accessibility (and other) software what the purpose of the
divis. More here in the draftroleattribute specification.Yes, it’s just semantic. Sending a
clickevent to the button should work.An earlier version of this answer (back in 2011) said:
…and provided the sample code and output below.
I cannot replicate the output now (two years later). Even if I go back to earlier versions of jQuery, they all trigger jQuery handlers, DOM0 handlers, and DOM2 handlers. The order isn’t necessarily the same between a real click and jQuery’s
clickfunction. I’ve tried jQuery versions 1.4, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.5, 1.5.1, 1.5.2, 1.6, and more recent releases such as 1.7.1, 1.8.3, 1.9.1, and 1.11.3 (the current 1.x release as of this writing). I can only conclude that it was a browser thing, and I don’t know what browser I was using. (Right now I’m using Chrome 26 and Firefox 20 to test.)Here’s a test which shows that indeed, jQuery handlers, DOM0 handlers, and DOM2 handlers are all (as of this writing!) triggered by jQuery’s
click: