0

我无法找到以下问题的解决方案。我想引用一个动态创建的 Raphael 形状。是否可以在 Raphael dom.node 数据上使用 jQuery find() 函数

$.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 样式 find()?

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


});
4

1 回答 1

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");    
    });
于 2012-03-12T10:28:03.153 回答