【发布时间】:2011-01-28 14:50:29
【问题描述】:
在我的页面中,有很多超链接。我想将所有带有 'uid' 属性的 'a' 更改为这样:
<a href=# uid="5526183">5526183</a>
成为
<a href=# uid="5526183">Afrig Aminuddin</a>
另一个例子
<a href=# uid="5526183">My name is 5526183</a>
成为
<a href=# uid="5526183">My name is Afrig Aminuddin</a>
首先:我会得到所有带有 'uid' 属性的 'a' 标签
var uid=$('a[uid]');
然后我调用该函数,该函数只会在页面加载后调用...
named(uid);
这是我的功能
function named(uid){
// here i'd like to do something with the 'uid' array in order it can be
// processed in the next line
// in the next line, the 'uid' must be unique
// so, before that i'd like to filter all the 'uid' array in order to
// filter the double 'uid'
FB.api(
{
method: 'fql.query',
query: 'SELECT name FROM user WHERE uid IN (5526183,1000014057,100001491471735)'
},
function(response) {
// change all the 'a' with 'uid' attribute here...
// response example
return response[0].name; //return the name of 5526183
return response[1].name; //return the name of 1000014057
return response[2].name; //return the name of 100001491471735
}
);}
【问题讨论】:
标签: javascript jquery facebook