Remove or hide svg element

后端 未结 1 1158
一向
一向 2020-12-11 00:24

is it possible to remove or hide svg element using css or jquery. I know how to \"edit\" div element using css. Something like this:

div[style=\"position: ab         


        
相关标签:
1条回答
  • 2020-12-11 01:21

    Use the SVG visibility attribute.

    https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/visibility

    The visibility attribute lets you control the visibility of graphical elements. With a value of hidden or collapse the current graphics element is invisible


    [update]

    However display: none; and opacity: 0 work too.

    But know that opacity (MDN Link) is the most computationally expensive (as it keeps the elements click event alive even though the element isn't displayed visually),

    then visibility,

    then display, https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/display.

    But rushing to use display isn't always the best because we get more control over the elements with visibility (i.e., "If you are trying to hide an entire group, except for one particular member of that group, use 'visibility' as it is overrideable in inheritance." link)

    SVG Resource

    0 讨论(0)
提交回复
热议问题