All,
I have the following bit of code:
[CODE]
<script>
jQuery(document).ready(function() {
var url=’http://search.twitter.com/search.json?callback=?&q=test’;
jQuery.getJSON(url,function(json){
jQuery.each(json.results,function(i,review){
jQuery(“#divroller_container”).append(‘<div class=”reviews” id=item’+i+’>’+review.text+'<br>Reviewed By: ‘+review.from_user+'</div>’);
//jQuery(“#divroller_container”.children()[i]).hide();
});
});
});
var hiddenDivs = [];
function start(pause, visible_divs) {
var container = jQuery(“#divroller_container”);
var divs = container.children();
var visible = visible_divs
alert(divs.length);
while (visible < divs.length) {
var removedDiv = jQuery(divs[divs.length – 1]).remove();
hiddenDivs.push(removedDiv);
divs = container.children();
}
setTimeout( function() {
roll(container, pause, visible)
}, pause);
}
function roll(container, pause, visible) {
container.prepend(hiddenDivs.pop());
hiddenDivs.unshift(jQuery(container.children()[visible]).remove());
//Efect
jQuery(container.children()[0]).hide();
jQuery(container.children()[0]).slideDown(“slow”);
//Repeat
setTimeout( function() {
roll(container, pause, visible)
}, pause);
}
</script>
<div id=”divroller_container”>
</div>
<script type=”text/javascript”>
start(2000, 1);
</script>
I’m baiscally trying to get some twitter feeds and the rotate them. I can get it and everything like that but for some reason the jQuery doesn’t pick up the divs that I appended to the container because when I alert the div.length like this:
[CODE]
alert(divs.length);
The result is always zero. The code works fine if I can populate that value but if I don’t have it in the code before hand it doesn’t work. However if I add a div to the container like this:
[CODE]
<div id=”item1″ class=”reviews”>
<a href=”http://ilkinbalkanay.blogspot.com/2007/11/my-favorite-shell-commands.html”>My favorite shell commands</a>
</div>
That same code:
[CODE]
alert(divs.length);
Will output a 1. I’m not sure how to have jquery recognize that I appended the divs earlier. Any help would be great! Thanks in advance!