Magurean Dan Sergiu Magurean Dan Sergiu - 2 months ago 7
jQuery Question

How to .load() into the div that has the link to the function

I want to make a dynamic site which loads the

div
content from other pages into the
div
content that has the links which use the function
.load()
. It works if the
div
you are changing is another
div
than the content
div
.

Here is the command that I think that should work:

<div class="container">
<div class="links">
<a href="#" id="button">CLick here</a><br />
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script>
$("#button").on("click", function(){
$("#container").load("example.php?q=2 #container > *");
});
</script>
</div>
</div>


If I replace
#container
with another
div
, the whole procedure works. But when I try to replace the container
div
it does absolutely nothing. In
example.php
there are some PHP functions which populate the inside of another div through MySQL.

How can I make the load function work on the upper
div
?

Answer

The problem is that instead of class(.) I appended the id tag(#). The solution was to add to the class container an id container. <div class="container" id="container">