JQuery 就绪函数无法加载我想要的内容
我试图确保我的 JQuery 就绪功能正常工作。从长远来看,我希望能够在页面加载后加载图像,但现在,我仅尝试使用文本,但它不起作用。这是我的代码。
//inside my html
<div id= "person_image">
<p> has not been replaced </p>
</div>
//the ready function... this is in another file, but I know it is accessing properly
//the made it text is displaying as it should
$(document).ready(function(){
alert("made it");
$("person_image").html("<p> replacement string </p>");
});
每当我重新加载页面时,什么都没有改变,它仍然显示“尚未被替换”。我对 JQuery 就绪函数做错了什么吗?
I'm trying to make sure that my JQuery ready function is working. In the long run, I want to be able to load an image once the page loads, but for now, I am trying it merely with text, and it is not working. Here is my code.
//inside my html
<div id= "person_image">
<p> has not been replaced </p>
</div>
//the ready function... this is in another file, but I know it is accessing properly
//the made it text is displaying as it should
$(document).ready(function(){
alert("made it");
$("person_image").html("<p> replacement string </p>");
});
Whenever I reload the page, nothing is changed and it still reads "has not been replaced". Am I doing something wrong with the JQuery ready function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您缺少
#
截至目前,您正在尝试访问元素
,而不是id
为的元素人物图像
。You are missing
#
As of now, you are trying to access an element
<person_image>
instead of something with theid
ofperson_image
.你忘记了“#”!
应该是:
You forgot the '#'!
should be:
尝试
$("#person_image").html("
替换字符串
");
而不是
$("person_image").html("
替换字符串
");
try
$("#person_image").html("<p> replacement string </p>");
instead of
$("person_image").html("<p> replacement string </p>");