Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,958
    Thanks
    120
    Thanked 76 Times in 76 Posts

    SVG - find path element by attribute

    Code:
    <svg width="600" height="400">
    <g transform="scale(0.3768252472915685) translate(247.72500000000008, 0)">
    <path class="jvectormap-region jvectormap-element" d="m 272.39276,333.19565 153.50948,0 c 43.2173,30.28397 86.00383,60.63807 0,111.95804 l -153.50948,0 z" 
    data-code="AT-2" fill="white" fill-opacity="1" stroke="none" stroke-width="0" stroke-opacity="1" fill-rule="evenodd">
    <path class="jvectormap-regio ...
    How to find path element by red data ?
    It is uique within path elements.
    Last edited by BubikolRamios; 12-30-2013 at 09:47 AM.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,471
    Thanks
    6
    Thanked 980 Times in 953 Posts
    I suppose you are using jQuery, given that the class names contain “jvectormap”. So I’d guess the easiest would be to do $('[data-code="AT-2"]')…, or to be more specific $('path[data-code="AT-2"]')…

  • Users who have thanked VIPStephan for this post:

    BubikolRamios (12-30-2013)

  • #3
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,958
    Thanks
    120
    Thanked 76 Times in 76 Posts
    Ok getting into that (jquery). New to that, only using some frame.

    Code:
    var child = $('#additional-map .jvectormap-container svg g path[data-code="AT-2"]')[0];
    I suppose now I could do DOM thing:

    Code:
    c.parentNode ...
    but looks like that does not work.

    Want to remove that DOM child and copy clone of it back to parent (read somewhere that should send it to top (namely z-index effect) of all paths on image ...)

    How to best do that ?
    Last edited by BubikolRamios; 12-30-2013 at 12:17 PM.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #4
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,958
    Thanks
    120
    Thanked 76 Times in 76 Posts
    Code:
             var c = $('#additional-map .jvectormap-container svg g path[data-code="AT-2"]').get(0);
            var c1 = $('#additional-map .jvectormap-container svg g path[data-code="AT-2"]')[0];
    What don't I see here. Aren't those two lines equivalent.
    get(0) gets me dom object, the second line not. What m'I missing ?
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •