I'm using Visual Studio 2013 WebForms, and I'm trying to call a javascript function when a dropdownlist (Asp:DropDownList) is changed.
However I am totally confused with this behavior. Could someone please tell me what is wrong?
This works
<asp:DropDownList ID="ddlList" CssClass="form-control" onchange="alert(1)" runat="server"></asp:DropDownList>
But nothing happens with this
$(document).ready(function () {
function test() {
alert(1);
}
});
<asp:DropDownList ID="ddlList" CssClass="form-control" onchange="test()" runat="server"></asp:DropDownList>
and this does not work either
$(document).ready(function () {
$('#ddlList').change(function(){
alert(1);
});
});
<asp:DropDownList ID="ddlList" CssClass="form-control" runat="server"></asp:DropDownList>
The hide() function works fine so I believe jquery itself works.
$("#divTextbox").hide();
This must be a simple thing but I've stack with this..
$('.form-control').change... does it work?