Javascript、jQueryのコードが思ったように動かなくて、再確認してみた。

JavascriptjQueryのコードが
思ったように動かない時に、再確認する


Javascriptの問題なのか、jQueryの問題なのかわからないが
挙動で不明なことがあったので、
以下のようなコードを書いてみた。


なるほど、
$(".image_view").html("jQuery image_view") が思ったように実行されないが、
http://h2ham.seesaa.net/article/141226477.html
のページを見て、挙動を確認するとよく理解できた。

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("jquery", "1.7");</script>
<link rel="stylesheet" href="./testbird.css" type="text/css">

<script type="text/javascript">
function init(){
  alert("on load init")
  $(".image_view_from_init").html("jQuery image_view_from_init ")
}
</script>

<script type="text/javascript">
  alert("head")
  $(".image_view").html("jQuery image_view")
</script>

</head>

<body onLoad="init()">
<script type="text/javascript">
alert("body")
</script>

<div class=image_view> Not Yet Changed.
</div>
<br /><br />

<div class=image_view_from_init> Not Yet Changed.
</div>

</body>
</html>