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

  • SEARCH
  • Home
  • 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 8300271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:30:20+00:00 2026-06-08T16:30:20+00:00

I need to include a SVG image(a map) in my html doc, and hopefully

  • 0

I need to include a SVG image(a map) in my html doc, and hopefully I can use JQuery to manipulate it. I looked this up on the Internet and some say you can’t manipulate the SVG directly. Some suggested the JQuery SVG plugin by Keith Wood, but I can’t open that link. Here is an example says that you can include SVG code directly into html5. Well for one thing, my SVG code is a little long so it looks awful if I put the code there, for another I’m still not sure how to manipulate it even if I do that.

So I think maybe I can use some framework, and I tried Raphael, but I need me to convert my SVG to another form and Raphael would render the image for me. But strangely the image became much smaller after I changed the SVG image. And I have trouble figuring out what’s wrong.

What I want to achieve is very similar to this page in the admob.com. This page seems to include the SVG code directly in the page.

Can anyone give some advice to achieve something like that?

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-06-08T16:30:23+00:00Added an answer on June 8, 2026 at 4:30 pm

    You don’t actually need jQuery to edit the SVG (but you can use it). Include the SVG doc using the object tags like so:

    <object data="mySVG.svg" type="image/svg+xml" id="mySVG"></object>
    

    You can then manipulate the DOM of the SVG by getting the document like so:

    var svgObject = document.getElementById("mySVG");
    
    moSVG.onload = function(){
        var svgDoc = moSVG.contentDocument;
        //Do SVG manipulation here, using svgDoc instead of document
    }
    

    Note the use of onload. Without it, you’re likely to get errors as the JS runs before the SVG has fully loaded (especially if you use images in the SVG).

    Once you’re sure the SVG’s loaded, you can use it in JavaScript outside of the onload statement.

    If, on the other hand, you want to embed JavaScript inside the SVG directly, you can use <script> tags as usual with one caveat: you need to use xlink if you want external JS (like the following example that imports jQuery)

    <script type="text/ecmascript" xlink:href="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"/>
    

    Internal JS can be described as follows:

    If you decided to use this, make sure to define xlink in the opening <svg> tag like so (don’t change the urls):

    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    

    However, remember that the JS that’s directly in the SVG cannot see anything on your HTML page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand preg_match_all can get me this information. I need include(xxxx); include_once(xxxx); require(xxxx); require_once(xxxx);
I need to include a html file inside a php file, I tried using
Programaticly, I need to include a google Maps map to automaticly generated pdf files.
Is it possible to include jQuery SVG source code in a standalone SVG document?
I need to include an html page (table of contents) on a CD/DVD. I'd
I need to include an image within the <a> tag of an ActionLink. What
I need to include a PHP script in my twig template. Is this possible?
I need to include a file that's in /include/mysample.html.php The file I am including
I need to include files within a function, and files use lots of variables
I need include asp mvc project in sharepoint, found this guide http://aspalliance.com/1944_Using_ASPNET_MVC_2_with_Sharepoint_Publishing.all but when

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.