jqueryready函数没有';不要装我想要的东西
我正在努力确保jqueryready函数正常工作。从长远来看,我希望能够在页面加载后加载图像,但现在,我只是尝试用文本加载图像,它不起作用。这是我的密码jqueryready函数没有';不要装我想要的东西,jquery,html,ready,Jquery,Html,Ready,我正在努力确保jqueryready函数正常工作。从长远来看,我希望能够在页面加载后加载图像,但现在,我只是尝试用文本加载图像,它不起作用。这是我的密码 //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 i
//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>");
});
//在我的html中
还没有被替换
//就绪功能。。。这是在另一个文件中,但我知道它正在正确访问
//“生成”文本按其应有的方式显示
$(文档).ready(函数(){
警惕(“成功”);
$(“person_image”).html(“替换字符串””;
});
每当我重新加载页面时,没有任何更改,仍然显示“尚未替换”。我对jqueryready函数做了什么错误吗 您缺少#
现在,您正在尝试访问元素
,而不是具有person\u image
的id
的元素代码>
而不是
$(“person\u image”).html(“替换字符串””代码>你忘了“#”了
$(“person\u image”).html(“替换字符串””;
应该是:
$("#person_image").html("<p> replacement string </p>");
$(“#person_image”).html(“替换字符串””;
为了扩展,选择符本质上是模仿CSS选择符的,因此它不是搜索特定ID,而是搜索特定类型的所有元素(即,
,
,或者在本例中是
)。
$("person_image").html("<p> replacement string </p>");
$("#person_image").html("<p> replacement string </p>");