Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3634438
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:46:43+00:00 2026-05-19T00:46:43+00:00

Does anybody have any experience with the Raphael.js SVG library? I’m using Raphael.js to

  • 0

Does anybody have any experience with the Raphael.js SVG library?

I’m using Raphael.js to create an SVG map (for use on smartphones) but I’m having trouble opening the map objects that Raphael creates up to outside interaction by jQuery and styling by css.

var R = Array();  
    R[1] = new Raphael("level1", 408, 286);  
    R[2] = new Raphael("level2", 408, 286);  
    R[3] = new Raphael("level3", 408, 286);  
    R[4] = new Raphael("level4", 408, 286);  
    R[5] = new Raphael("level5", 408, 286);  

var attr = {  
    fill: "#ccc",  
    stroke: "#000",  
    "stroke-width": 0.5,  
    "stroke-linecap": "square",  
    "stroke-linejoin": "miter"  
};  

// loop through a bunch of objects (not shown for brevity)
    // in the end, I end up with a couple hundred objects drawn by Raphael  

    var o = R[fID].path(coordstring).attr(attr);  

    // creates an #o[ID] id value that jQuery can target 
    o.node.id = "o"+$(this).attr('id'); // id value comes from data source  

    o.click(function(){  
        highlightMapObject(this.node.id.substr(1));                             
    );  

// end loop  

// accessed from the o.click and from outside in jQuery
function highlightMapObject(oid){  
    var $target = $("#o"+oid);  
    $target.addClass('highlight');  
}  

The issue I seem to be running into is that trying to add a class to the Raphael object doesn’t work, or if it is working, the CSS attributes of that class (like changed background colors, etc) aren’t being applied.

So if my .highlight class is:

.highlight { background-color: #f00; }

That is either not being applied, or isn’t overwriting the fill:"ccc" from the original Raphael attrs. My guess is that because the ID being targeted by jQuery is on the Raphael object NODE rather than the object itself, that’s probably part of the problem.

I’ve seen lots of advice to avoid node altogether when dealing with Raphael, but it seems to be the only way I’ve found to open a Raphael object up to outside targeting (in this case via jQuery).

I don’t have to use CSS to achieve the style change on these objects, but I do have to be able to achieve that change externally (via jQuery – in response to external highlight requests, etc) rather than all internally (via Raphael and only in response to object clicks).

Ideas?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T00:46:44+00:00Added an answer on May 19, 2026 at 12:46 am

    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');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anybody have any experience with different fonts for OCR? I am generating an
I have three easy questions. Does anybody use QuickTest Pro for automated testing? Any
Does anybody have any reference material that details Cauchy-Reed algorithm? Googling for Cauchy-Reed Solomon
Does anybody use the Class Designer much in Visual Studio? I have downloaded the
Does anybody have a short code sample that can be run in the VS
I've been looking for a simple regex for URLs, does anybody have one handy
I'm struggling to understand Dependency Properties in Silverlight 2. Does anybody have a good
I have to analyse some existing Erlang code. Does anybody knows about a tool
Does anybody know any good resources for learning how to program CIL with in-depth
Does anybody recommend a design pattern for taking a binary data file, parsing parts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.