下面的 jQuery 示例应该将一些文本放入 div,但它没有。我试过 Firefox、Google Chrome 和 Internet Explorer。
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" language="javascript"></script>
<script language="javascript">
$(window).load(function() {
$('adiv').html('<p>hello world</p>');
alert('done');
});
</script>
</head>
<body>
<div id="adiv">
</div>
</body>
</html>
抱歉,这可能很愚蠢,但我卡住了。
最佳答案
更改$('adiv').html('<p>hello world</p>');
到
$('#adiv').html('<p>hello world</p>');
关于javascript - 这个 jQuery 示例有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2663375/