<!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 后集中输入。但是没有用,为什么呢?