I've added jQuery version 3.4.1 on the main Layout view in MVC and I've another view called Register with the following simple javascript code:
<script src="~/Scripts/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#btnRegister').click(function () {
$('#successModal').modal('show');
})
});
</script>
But clicking btnRegister is not firing in the browser.
This is causing due to the Layout view for some reason. To test this condition, when I excluded the Layout view from the Register view and added jQuery v3.4.1 to the Register view, this code started running as expected.
I've made it very sure that no other javaScript library is used by both Layout and Register views except the given 2 libraries (jQuery v3.4.1 & bootstrap.min.js). For those who want to have a look at the stretched markup in the browser, I've pasted page-source here (https://pastebin.com/U3n3XCbh).
$(document).ready()with because you are using each and element calling separate event. And let me know Your register page include layout or not and your register page reload or loading content using jquery or ajax response?Registerpage is includingLayout.Registerpage is not loading or reloading content using jQuery or AJAX response at this stage. Can you please demonstrate what you meant by trying with$(document).ready(). I'm sorry I couldn't understand it.btnRegisterid.