2011-08-29 30 views
2

嗯,我的問題很簡單。RaphaelJS + jQuery:如何爲路徑定義ID和CLASSES

我正在使用RaphaelJS製作懸停效果的國家地圖,但我如何獲得懸停狀態ID?

想象一下,你有這個例子路徑。

var path = paper.path('coordinates_here'); 

如何用jQuery識別這條路徑? 例如:

$('#myPathId').mouseenter(function(){ 
     //do something here 
    }); 

回答

4

您可以使用內置的事件像Raphaeljs結合:

path.mouseover(function (event) { 
    //do something 
}); 

或你,如果你真的想使用jQuery做事件綁定,你可以這樣做:

$(path.node).mouseenter(function(){ 
     //do something here 
    }); 

假設

var path = paper.path('coordinates_here');