Forum Moderators: open

Message Too Old, No Replies

OnFocus event on DIV

         

hansem

3:21 pm on Aug 23, 2005 (gmt 0)

10+ Year Member



Hi, I've got a div that has several inputs on it. When on of them has focus I'd like to change the class of the div.

In Mozilla/Firefox I can use <div onfocus="alert(this.id);">........</div>

Is there any way to also use this in IE?

I've tried attachEvent and element.onfocus = ....;

Anyone suggestions?

I've got a workaround and put it on the onfocus of the inputs but this isn't what I want.

Marco

sometimesIcan

7:08 pm on Aug 30, 2005 (gmt 0)



Yes you can get onfocus to work with ie. See the excellent code at [htmldog.com...] This actually dowa <a> tags rather than <div>, but I guess it would work with divs. It's actually designed to apply a class to the focused element, but I have used it to call a further function, ie what the original onfocus would have done and it works well.