RaphaelJS Set.forEach() [英] RaphaelJS Set.forEach()

查看:34
本文介绍了RaphaelJS Set.forEach()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在文档 raphaeljs 中阅读了 Set.forEach 的描述,并且可以'不明白这个怎么运作.请任何人都可以给我一个使用示例.

I read in the documentation raphaeljs description of Set.forEach, and can't understand how it works. Please can anyone give me an example of usage.

推荐答案

这里有一个工作示例:

http://jsfiddle.net/9X6rM/

这是它的重要部分:

set.forEach(function(e){
    e.attr({fill:'#000'})
})

一开始有点棘手,但是当你得到它时它非常方便.您需要将要在每个元素上执行的函数传递给 forEach() 方法,并且该函数需要具有与参数一样的变量名称以绑定到该元素.所以在这种情况下 e 是正在处理的矩形.明白了吗?

Its a little bit tricky at first, but its pretty handy when you get it. You need to pass to the forEach() method the function that you want to execute on each element, and this function need to have, like an argument, a variable name to bind to the element. So in this case e is the rectangle that is being processed. Got it?

这篇关于RaphaelJS Set.forEach()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆