简体   繁体   中英

select the children with only some elements

I want to select children of some elements and reject other elements.

please refer below HTML.

    <g id="container_svg_SeriesGroup_0" transform="translate(77,465)">
    <defs>
<linearGradient id="container_svg_symbol0Gradient" x1="0%" y1="0%" x2="0%" y2="600%"><stop offset="0" stop-color="gray" stop-opacity="1"/><stop offset="0.5" stop-color="blue" stop-opacity="1"/>
</linearGradient>
</defs>
<path id="container_svg_rectsymbol0" fill="url(#container_svg_symbol0Gradient)" stroke-width="1" stroke="Gray" d="M -5 -450 L 5 -450 L 5 -440 L -5 -440 L -5 -450"/>
<defs>
<linearGradient id="container_svg_symbol1Gradient" x1="0%" y1="0%" x2="0%" y2="600%"><stop offset="0" stop-color="gray" stop-opacity="1"/><stop offset="0.5" stop-color="blue" stop-opacity="1"/></linearGradient>
</defs>
<path id="container_svg_rectsymbol1" fill="url(#container_svg_symbol1Gradient)" stroke-width="1" stroke="Gray" d="M 73.1111111111111 -71.75 L 83.1111111111111 -71.75 L 83.1111111111111 -61.75 L 73.1111111111111 -61.75 L 73.1111111111111 -71.75" transform="scale(1)"/>
...................
</g>

i want to select children of this group "container_svg_SeriesGroup_0" but not selecting "defs" group. i want to find the other elements instead of "defs"

i tried like below

$("#container_svg_SeriesGroup_0").children("path")

it returns path element. but in My DOM any kind of elements will be placed in this group"container_svg_SeriesGroup_0"

so i just not select "defs" group and select other elements direct children of that group.

expecting answer like using ".not" selector in jquery.

Thanks,

Siva

尝试这个 :

  $('#container_svg_SeriesGroup_0 > :not(defs)');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM