How do I apply CSS styles to Raphael.js objects using jQuery?

瘦欲@ 提交于 2019-12-03 12:40:47
Marcus Whybrow

I am not exactly sure what you code is doing, but if you want to get a jQuery object out of a Raphael object then do this:

var $jQueryObject = $(raphaelObject.node);

From there you can use jQuery to add a class:

$jQueryObject.addClass('highlight');

I also found that if you remove the inline styles after rendering the path with raphael.

$('#somediv path').removeAttr('fill').removeAttr('stroke');

then you can style them how ever you want using css

#somediv path { fill: white; }
#somediv:hover path { fill: blue; }

Or you add a class as an attribute

$jQueryObject.attr('class', 'highlight');

This will work instead of

$jQueryObject.addClass('highlight');
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!