Fire onmouseover event when element is disabled

后端 未结 6 995
陌清茗
陌清茗 2020-12-09 18:24

I have some controls that I need to disable when users don\'t have edit priveleges, but are sometimes not wide enough to show the entire text of the selected option element.

6条回答
  •  感动是毒
    2020-12-09 18:59

    I know this is an old post, but hopefully this answer will clarify how @Diodeus answer can be implemented!

    Disabled elements do not fire events, e.g. users cannot hover or click them to trigger a popover (or tooltip). As a workaround, you can however wrap a

    or around the disabled element and listen to the event fired on that element instead.

    NOTE! Using onmouseover and onmouseout in the wrapper

    will not work as expected in Chrome (v69). But will however work in IE. Which is why I recommend users to use onmouseenter and onmouseleave instead, which is working great both in IE and in Chrome.

       
    
      

    I've put together a JS fiddle with some examples here: http://jsfiddle.net/Dr4co/tg6134ju/

提交回复
热议问题