I am trying to create a script that shows my login modal on page load. I have a button that opens the register modal and closes the login modal if clicked.
Here is the script I am using:
$(document).ready(function(){
$('#loginmodal').modal('show')
});
$(".hidelogopenreg").click( function()
{
$('#loginmodal').modal('hide')
$('#registermodal').modal('show')
}
);
Even though the works correctly, I fear it's using bad practices as I have little JavaScript knowledge and don't want to have to resolve problems further down the line.
Is this correct and efficient or is there a better way of writing this?
Another problem I had is that hiding a modal causes the body to shift to the right on close, to fix this I added:
body {
padding-right:0px !important;
margin-right:0px !important;
}
Could this also cause problems for me?