AFAI read and glance at other questions, what appears in a HTML document, the lines executed in order. I think same thing is applied to a Javascript file. I expect in the following code, first background is painted as yellow then immediately get readyyyy
message, but total opposite case happens. alert()
runs firstly then page is yellow. Why?
js code,
$('body').css("background", "yellow");
function f() {
alert("readyyyy");
}
$(f()); // same as $(document).ready(…)
html code,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<p>Testing...</p>
<script src="jquery.js"></script>
<script src="Test.js"></script>
</body>
</html>