<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
</head><
<body>
<button onClick="change()">Change Input</button>
<div>
<input value="It works">
</div>
<script>
function change()
{
$('div').html('<input value="it didnt work">');
}
$('input').focus(function ()
{
if (this.value == this.defaultValue)
{
this.value = '';
}
}).blur(function()
{
if (this.value == '')
{
this.value = this.defaultValue;
}
});
</script>
</body>
</html>
ここでは、divのhtmlを変更した後、入力に焦点を合わせようとします。しかし、それはうまくいきませんでした、なぜですか?