I have the following jQuery function in my ASP.net user control:
<head>
<title></title>
<script src="~/Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript" src="~/Scripts/jquery-1.4.1.js">
$(document).ready(function () {
alert("In Jquery");
$("[id*=RadioButtonListYesNo]").change(function () {
alert("In Jquery");
var res = $('input[type="radio"]:checked').val();
if (res == '1') {
$("#divFAFMQues").css("visibility", "hidden");
$("#divFAFM").css("visibility", "hidden");
}
else {
$("#divFAFMQues").css("visibility", "visible");
$("#divFAFM").css("visibility", "visible");
}
});
});
</script>
</head>
The document.ready function is not getting fired when the page containing the user control is getting loaded. Please help.
First, please check your jQuery file is importing correctly. Try checking with cdn first.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
Try to remove src
element from your 2nd script tag:
<script language="javascript" type="text/javascript" src="~/Scripts/jquery-1.4.1.js">
to
<script language="javascript" type="text/javascript">
complete code:
<asp: Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script src="~/Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
alert("In Jquery");
});
</script>
</asp:Content>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.