I am new to jQuery and fiddling around with trying to add new elements to the DOM after a new node has been inserted into the DOM.
Let's say I have a poll. After the user votes, a new div with a class of .voted
is inserted into the div that contained the poll. If I had a hidden div that I wanted to insert and show only when this new div has been added to the DOM, would this be possible?
I've been doing research on the jQuery site and so far, the closest I came up with was something like this:
$('.hidden-div').livequery(function() {
appendTo('.voted');
});
I tried this on my site, but as expected, it didn't work. Is there a way to achieve this using jQuery?
Edit: Here is a simplified version of the markup:
Before user has voted:
<div id="poll">
(poll here)
</div>
<div id="hidden-div" style="display:none">content</div>
After user has voted:
<div id="poll">
<div class="voted">
(some content here) <-- in here----------|
</div> |
</div> |
<div id="hidden-div" style="display:none">content</div> <-- I want this div..|