visibility does not work
Hi guys, I have a simple list, when I click on an item of the list I want to display the icon of that item and hide other icons. I toggle the value of
visibility
from hidden
to visible
but the icon does not display as I expected. It works when I use display
instead of visibility
. Can anyone help me explain why?10 Replies
You can take a look here : https://jsbin.com/zubitijase/1/edit?html,css,js,output
JS Bin
A live pastebin for HTML, CSS & JavaScript and a range of processors, including SCSS, CoffeeScript, Jade and more...
I haven't yet been able to work out the actual cause but, if you change the id of the "defs" so that they are distinct, it does work as expected.
aside from your specific question, you could also just use radio buttons for this
Sorry, I dont get it. Wdym "change the id of the 'defs' "
Can you give me an example?
Sorry, I said, "defs". The ID is set on the clipPath.
Both of your elements use the same id on the clipPath "#clip0_1599_15824".
I don't know why this should cause the issue but it is. This is probably a could example of why you should never repeat ids in HTML.
Changing this id (and the url that references it) to something unique will resolve the issue.
To be honest the SVGs here are overly complicated for what you want to achieve (a checkmark). Something like this (adapted from Tabler Icons) achieves the same result without the need for ids, clip-paths or defintions:
If you are required to use the specific SVG that you have in the code, then you could look at SVG templates but that is another matter.
ids cant be repeated
that breaks svgs
here an example of the 'radio-button' route (with Chris' svg)
https://codepen.io/MarkBoots/pen/mybbwKB
(updated with use symbol)
which is why people should use <symbols> for svgs that will be used more than once
I got it. Thanks guys