2012-03-12 43 views
0

我无法找到解决以下问题的解决方案。我想参考已经在飞行中创建的Raphael形状。是否有可能使用了jQuery找到与特定数据attr元素声明拉斐尔dom.node数据参考动态拉斐尔对象

$.each(count, function(i, feed){ 
    var against = feed.against; 
    var country = feed.country; 
    var x = feed.lat; 
    var y = feed.long; 
    feed = R.rect(500-(y*3), 500-(x*3),50, 50).attr("fill","rgba(0,0,0,.4)").attr("stroke", "rgba(0,0,0,0)").data("country", country).data("against", against); 
    $(feed[0]).hover(function() { 
    feed.attr("fill","#FFF"); 

     var against = feed.data('against'); 

//这里是有可能做一个jQuery风格的发现()()函数?

},function() { 
     feed.attr("fill","#000");  
    }); 


}); 

回答

0

我看到需要完成一些更正,为此。以下列表是更正后的代码。 我没有检查过代码。

$(feed[0]).hover(function() { 
     var dthis = $(this), against = dthis.data('against'); 
     dthis.attr("fill","#FFF"); 
     // here is it possible to do a jQuery style find() on elements with a specific data attr? 
     if(against && against == 'some_Speficic_value'){ 
      // do some thing on dthis 
     } 
    },function() { 
     var dthis = $(this); 
     dthis.attr("fill","#000");  
    });