JavaScript hide/show element

前端 未结 11 1835
死守一世寂寞
死守一世寂寞 2020-11-22 00:08

How could I hide the \'Edit\'-link after I press it? and also can I hide the \"lorem ipsum\" text when I press edit?



        
11条回答
  •  生来不讨喜
    2020-11-22 01:01

    You should think JS for behaviour, and CSS for visual candy as much as possible. By changing your HTML a bit :

    
        Edit
        
           
        
        Lorem ipsum ... 
    
    

    You'll be able to switch from one view to the other simply using CSS rules :

    td.post-editing > a.post-edit-btn,
    td.post-editing > span.post-text,
    td.post > span.post-answer
    {
        display : none;
    }
    

    And JS code that switch between the two classes

    
    

提交回复
热议问题