JavaScript hide/show element

前端 未结 11 1634
死守一世寂寞
死守一世寂寞 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条回答
  •  旧时难觅i
    2020-11-22 01:01

    Just create hide and show methods yourself for all elements, as follows

    Element.prototype.hide = function() {
        this.style.display = 'none';
    }
    Element.prototype.show = function() {
        this.style.display = '';
    }
    

    After this you can use the methods with the usual element identifiers like in these examples:

    document.getElementByTagName('div')[3].hide();
    document.getElementById('thing').show();
    

    or:

    
    

提交回复
热议问题