How to apply CSS style to all elements with same ID using one button?

后端 未结 6 528
小蘑菇
小蘑菇 2021-01-26 06:59

My idea was to create a button to hide/show all hidden text (Hide by highlighting the text in black, show by making the background color of the text transparent). But the codes,

6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-26 07:25

    id is unique, so it's not valid to have multiple instances [http://www.tizag.com/cssT/cssid.php] - you could however use a class and then select all instance with $(".className") (assuming jQuery). This answer How to getElementByClass instead of GetElementById with Javascript? contains a lot of helpful pointers

提交回复
热议问题