JQuery 就绪函数无法加载我想要的内容

发布于 2024-12-25 02:58:21 字数 540 浏览 2 评论 0原文

我试图确保我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不再让梦枯萎 2025-01-01 02:58:21

您缺少 #

$("#person_image")

截至目前,您正在尝试访问元素 ,而不是 id的元素人物图像

You are missing #

$("#person_image")

As of now, you are trying to access an element <person_image> instead of something with the id of person_image.

赏烟花じ飞满天 2025-01-01 02:58:21

你忘记了“#”!

$("person_image").html("<p> replacement string </p>");

应该是:

$("#person_image").html("<p> replacement string </p>");

You forgot the '#'!

$("person_image").html("<p> replacement string </p>");

should be:

$("#person_image").html("<p> replacement string </p>");
热情消退 2025-01-01 02:58:21

尝试 $("#person_image").html("

替换字符串

");
而不是
$("person_image").html("

替换字符串

");

try $("#person_image").html("<p> replacement string </p>");
instead of
$("person_image").html("<p> replacement string </p>");

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文