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 就绪功能做错了吗?

4

3 回答 3

4

你不见了#

$("#person_image")

到目前为止,您正在尝试访问一个元素而不是使用of<person_image>的东西。idperson_image

于 2012-01-06T20:39:01.423 回答
3

你忘记了“#”!

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

应该:

$("#person_image").html("<p> replacement string </p>");
于 2012-01-06T20:39:59.800 回答
2

尝试$("#person_image").html("<p> replacement string </p>"); 代替 $("person_image").html("<p> replacement string </p>");

于 2012-01-06T20:39:47.163 回答