禁用元素时触发onmouseover事件 [英] Fire onmouseover event when element is disabled

查看:495
本文介绍了禁用元素时触发onmouseover事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户没有编辑权限时,我需要禁用一些控件,但有时不够宽,无法显示所选选项元素的全部文本。在这种情况下,我已经添加了一个带有ASP.NET和以下代码的工具提示

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. In which case I've added a tool tip with ASP.NET and the following code

ddl.Attributes.Add("onmouseover", "this.title=this.options[this.selectedIndex].title")

这个控件在启用时有效,但在禁用时无效。

This works when the control is enabled, but doesn't work when it is disabled.

鼠标悬停时,以下警报不会触发选择元素:

The following alert will not fire when a mouse is over the select element:

<select disabled="disabled" onmouseover="alert('hi');">
    <option>Disabled</option>
</select>

请参阅此 小提琴

Q 我可以触发 onmouseover 事件控制禁用?

Q: Can I fire the onmouseover event for controls that are disabled?

推荐答案

禁用的元素不会触发事件。但是,您可以在元素顶部放置一个DIV,然后倾听在该元素上触发的事件。

Disabled elements do not fire events. You can however place a DIV over top of the element and listen to the event fired on that element instead.

这篇关于禁用元素时触发onmouseover事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆