
05.05.2014/14:42
Tuy code này trên mạng đã share rất nhiều. Hôm nay mình share lại cho các bạn tham khảo. Chỉ với 1 dòng lệnh kết hợp với các thẻ div là bạn có thể tạo 1 button cho phép ẩn hiện nội dung của bạn khi click vào nó. Có 2 code ẩn hiện nội dung cho các bạn lựa chọn:Code 1:
<div><div><input 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'; }" style="font-size: 10px; margin: 0px; padding: 0px; width: 75px;" type="button" value="Xem" /></div><div><div style="display: none;">{điền phần nội dung bạn muốn ẩn vào đây}</div></div></div>
Copy code 1:
Nếu như bài đăng quá dài, nếu muốn ẩn , thì phải kéo lên trên để thực hiện thao tác nhấn nút Ẩn , gây phiền phức. Để xử lý tình trạng gây khó khăn cho người đọc, Các bạn có thể dùng code dưới đây.
Code 2:
<div style="margin: 5px 20px 20px;"><div class="smallfont" style="margin-bottom: 0px;">Spoiler: <input 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'; }" style="font-size: 10px; margin: 0px; padding: 0px; width: 45px;" type="button" value="Xem" /></div><div><div style="display: none;">{điền phần nội dung bạn muốn ẩn vào đây}</div><input 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'; }" style="font-size: 10px; margin: 0px; padding: 0px; width: 45px;" type="button" value="Ẩn" /></div></div>
Copy code 2:
Chúc bạn thành công!
Nguồn: Võ Văn Tùng - cdqtkd5a.blogspot.in

Tag:
Bạn đến từ:
Tool tiện ích admin,KhoGame360,Blog thủ thuật,kenh380
,truyen23h
,tai hinh nen naruto,kenhpro - wap hay,vmt - wap hay, Trần Phú Hiền Blog
,truyen23h
,tai hinh nen naruto,kenhpro - wap hay,vmt - wap hay, Trần Phú Hiền Blog