2009-10-07 23 views

回答

1

像这样:

$('a').each(function() 
{ 
    alert(this.id + ': ' + $(this).text()); 
}); 
1

您可以使用:

$("your-selector-here").attr("id"); 

获得ID和:

$("your-selector-here").text(); 

得到封闭在链接的文本。

您需要决定如何最好地使用jQuery选择器来识别每个链接,并在上面的示例中用您的选择器替换“your-selector-here”。

0

如果你的链接是简单的锚,你可以这样来做:

要获取ID:

$("a").each(function() { $(this).attr("id"); }); 

来获取值或文本:

$("a").each(function() { $(this).text(); });