javascript - Jquery show loading div while waiting for script to finish -
i have javascript looks this
$("#loading").show(); // script takes time $("#loading").hide();
i want show loading dialog wait script end , close it. doesn't work this. opens loading dialog after script finished , stays open.
what's problem?
try use toggle
$(document).ready(function(){ $("button").click(function(){ $("#loading").toggle(); }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <p id="loading">loading</p> <button>show hide loading</button>
Comments
Post a Comment