开发者

Is there any jQuery method like do method as in my example?

I know that i can simply write a plugin for it and i know that i can do this manually. I am just looking simple way if jQuery provide such as option.

Actualy each method will work as expected but it does not make feel it is effective way because it is clear that there is no iteration. There is only one element. Check example开发者_Python百科 below.

$('a').first().do(function(element){
  //do your job
}).end().eq(2).do(function(element){
  // do another job
});


jQuery each()

$('a').first().each(function(element){
  $(this).html("foo");
}).end().eq(2).each(function(element){
  $(this).html("bar");
});


each would work instead of do, even though you are only dealing with one item.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜