As I understand JS code is executed line by line. Why then in the code below alert is performed before hide?
$(document).ready(function(){
$("button").click(function(){
$("p").hide();
alert("The paragraph is now hidden");
});
});
That is because the DOM manipulations are usually a bit heavy and are rendered after all the statements in the mentioned event loop are executed.
As @Pointy rightly mentioned, the layout is rendered only after the registered statements are executed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With