Zack
Zack

Reputation: 13972

JQuery ready function doesn't load what I want

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?

Upvotes: 0

Views: 80

Answers (3)

chrisn
chrisn

Reputation: 2135

You forgot the '#'!

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

should be:

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

Upvotes: 3

Snake Eyes
Snake Eyes

Reputation: 16764

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

Upvotes: 2

James Montagne
James Montagne

Reputation: 78710

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.

Upvotes: 4

Related Questions