$("#bc [id$=_dropdownID]").change(function() {
if (this.value == '2' || this.value == '3') {
$("#bc .pnl").show();
}
else {
$("#bc .pnl").hide();
}
我在 jQuery 中有以下代码。有什么办法可以用 c# 枚举替换上面代码中的硬编码常量 2 和 3 吗? jQuery 支持枚举吗?如果支持,如何实现? 欢迎任何建议......
最佳答案
您必须像这样在 JavaScript 中复制枚举:
var myEnum = {
OneValue: 2,
AnotherValue: 3
};
然后你可以像这样使用它:
this.value === myEnum.OneValue || this.value === myEnum.AnotherValue;
关于javascript - jQuery 中的枚举?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3625805/