Hi John,
It works just like a "for" loop. You can put the "i" in the anonymous
function argument for .each(). For example:
$('p').each(function(index) {
alert('This is paragraph number ' + index);
});
(I used "index" instead of "i" because I'm kind of dense, and it
helps to remind me what it is).
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Feb 21, 2007, at 3:11 PM, john smith wrote:
Sorry all Im still a newb to jquery. Ive been messing around with
using jquery for grabbing and displaying rss feed info. A lot less
code then using straight javascript. what Im not quite clear on is
how you grab a specific count from doing an .each
For example if I grab a feed with the jquery code below
// count for lines display
var items_count = 10;
// feed location
var feed = my.xml';
// replace url for link
var u = 'http://www.mypage.html?txtSearch='
$(document).ready(function(){
$.get(feed, function(xml){
$("item", xml).each(function(){
$(this).find("item").each(function(){
html += "";
}).end().find("title").each(function(){
html += "<a href='" + u + this.text +
"'>" + this.text + "</a><br>";
});
});
$("#feed").html(html).slideDown("slow");
});
});
Using jquery how do I do a for each count like:
for(var i=0; i<items_count; i++) {
Access over 1 million songs - Yahoo! Music Unlimited.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/