Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在禁用的asp.net下拉列表中添加警报?_Javascript_Jquery_Asp.net_Json - Fatal编程技术网

Javascript 如何在禁用的asp.net下拉列表中添加警报?

Javascript 如何在禁用的asp.net下拉列表中添加警报?,javascript,jquery,asp.net,json,Javascript,Jquery,Asp.net,Json,我有这样一个下拉列表: <asp:DropDownList ID="cboJPRem" class="jprem" runat="server"> <asp:ListItem Value="None" Selected="True" Text="None"></asp:ListItem> <asp:ListItem Value="1day" Text="1 day"></asp:ListItem> </asp

我有这样一个下拉列表:

<asp:DropDownList ID="cboJPRem" class="jprem" runat="server">
     <asp:ListItem Value="None" Selected="True" Text="None"></asp:ListItem>
     <asp:ListItem Value="1day" Text="1 day"></asp:ListItem> 
</asp:DropDownList>
上面的代码是我尝试添加警报的代码,但它不起作用。 有什么方法可以做到这一点吗?

检查代码上的注释:)


是的,有一种方法,叫做jQuery。禁用的元素不能引发事件。可能会有帮助
$(document).ready(function() {
            $("#cboJPRem").change(function(){
                if($("#cboJPRem:selected").attr("id") == "cboXyz"){
                    alert("To enable this drop down, change the value of 'check A'");
                }
            });

        });
$("#cboJPRem").on('change', function() {

    //this will help you to retrive the selected value. 
    var yourVal = $('option:selected', this).attr("id"); 

    //confirm if value is retrived properly
    console.log(yourVal);

    if(yourVal == "cboXyz") {
        //do your stuff
    }
});