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

后端 未结 6 567
小蘑菇
小蘑菇 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:28

    I oppose the Same ID concept... But Try like below will be a answer to your question....

    Fiddle Example : http://jsfiddle.net/RYh7U/65/

    CSS

    .mask
    {
    color : red;
    }
    

    Javascript :

    function change()
    {
     var elements = document.getElementById("p2").parentNode.getElementsByTagName("span");
        for(var i=0; i

提交回复
热议问题