Code Tạo button ẩn hiện nội dung - Điện Lực Lệ Thuỷ

Thứ Năm, 15 tháng 12, 2016

Code Tạo button ẩn hiện nội dung


Hôm nay mưa gió quá !!! Nên mình không tiện đi chơi nên ngồi ở nhà làm mấy việc còn dư động lại, nên cũng có cần đoạn code này nên mình cũng tiền chia sẽ cho mọi người luôn, quả thật trên mạng chia sẽ rất nhiều về thủ thuật này nên mình cũng tiện chia sẽ luôn cho những ai cần ^^.

Đoạn code hoàn toàn đơn giản không cầu kỳ phức tạp nhé mọi người

<div> <div> <input type="button" value="Xem" style="width:75px; font-size:11px; margin:0px; padding:4px; border="1"" onclick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = '';this.innerText = ''; this.value = 'Ẩn'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Xem'; }"> </div> <div> <div style="display: none; border:#4F4F4F 1px solid; padding: 4px; background:# ">
NỘI_DUNG 
</div> 
</div>
</div>

Còn đây là DEMO của mình ...

2 nhận xét