[英]Show tooltip on mouseover of a disabled dropdown
countLabel() == 0 ? $('#' + uniqueValueee + 'AndOrSelection').prop("disabled", true) : $('#' + uniqueValueee + 'AndOrSelection').prop("disabled", false);
Using the above code I am able to disable the selection of the dropdown. 使用上面的代码,我可以禁用下拉列表的选择。 I also want to show a tooltip saying why the dropdown is disabled. 我还想显示一个工具提示,说明为什么禁用下拉列表。 For that I have written a function on @onmouseover = "showToolTip(this.id)"
on my razor dropdownlist. 为此,我在剃须刀下拉列表的@onmouseover = "showToolTip(this.id)"
上编写了一个函数。
function showToolTip(id)
{
alert(id);
}
If i write the code on other dropdowns which are enabled
it works fine. 如果我在enabled
其他下拉菜单上编写代码,则可以正常工作。 But when the disabled dropdown is mose overed, the js function doesn't fire. 但是,当禁用下拉菜单时,js函数不会触发。 Plus in chorome i am also not able to inspect element. 再加上在脊索肌中,我也无法检查元素。 Please help. 请帮忙。
Try this on your razor view. 在剃刀视图上尝试一下。 I tested it and it is working perfectly for both condition (ddl enabled & disabled): 我对其进行了测试,并且在两种情况下(ddl已启用和已禁用)都可以正常运行:
@Html.DropDownListFor(m => m.City, new SelectList(Model.Lookups.Where(x => x.LookupType == "City"),
"LookupID", "LookupValue"), "---- Select ----", new { disabled= true, @Title= "Tooltip here" })
Please attention to the properties below: 请注意以下属性:
new { disabled= true, @Title= "Tooltip here" }
Then here is the result with enabled and disabled option: 然后是启用和禁用选项的结果:
Hope this helps... 希望这可以帮助...
Usually, HTML disabled elements do not facilitate any JS events like hover, click, etc. For your purpose, you put a div
overlay with higher z-index
such that it acts as a disabled area. 通常,禁用HTML的元素不会促进任何JS事件(例如,悬停,单击等)。出于您的目的,您将div
叠加层具有较高的z-index
,使其充当了禁用区域。 Then you can define the hover event on the div
itself. 然后,您可以在div
本身上定义悬停事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.