I feel really stupid asking for this, but remarkably I’m banging my head for an hour already. Here is the code:
<div id="img1" onfocus="alert('test');" onblur="alert('test');">
<img id="image1" name="image1" src="image1.jpg" alt="Pciture 1">
</div>
Both events (Focus/Blur) should call a function, but even this simple test (alert) doesn’t work. Both of these tags are in the body section, tried changing the DOCTYPE definition – no effect.
W3 spew an error:
there is no attribute "ONFOCUS"
My main goal is to use the events directly on the img tags, but for some reason that doesn’t work either.
<div>and<img>don’t normally have a focus or blur event, but you can try setting a tabindex on it as a workaround. It’s a bit strange though.http://www.quirksmode.org/dom/events/blurfocus.html