[英]How to hide specific dom element in html2canvas?
我使用以下插件以PNG格式導出表格數據,
<li><a href="#" onClick ="$('#datawtable').tableExport({type:'excel',escape:'false', ignoreColumn:[0, 4]});"> <img src='icons/xls.png' width='24px'> XLS</a></li>
<li><a href="#" onClick ="$('#datawtable').tableExport({type:'doc',escape:'false', ignoreColumn:[0, 4]});"> <img src='icons/word.png' width='24px'> Word</a></li>
<li><a href="#" onClick ="$('#datawtable').tableExport({type:'png',escape:'false'});"> <img src='icons/png.png' width='24px'> PNG</a></li>
<script type="text/javascript" src="js/tableExport.js"></script>
<script type="text/javascript" src="js/jquery.base64.js"></script>
<script type="text/javascript" src="js/html2canvas.js"></script>
這樣的輸出, 在這里,我想隱藏我檢查過此https://github.com/niklasvh/html2canvas/issues/126的 “照片”和“選項”列,但沒有得到它,我該怎么做。
由於采用表格格式,因此可以使用firs-child
和last-child
來訪問表的第一列和最后一列。
$("#tableID th:first-child, #tableID th:last-child, #tableID td:first-child, #tableID td:last-child").hide();
要么
$("#tableID tr th:first-child, #tableID tr th:last-child, #tableID tr td:first-child, #tableID tr td:last-child").hide();
使用html2canvas渲染之前,您需要隱藏元素。
在html2canvas渲染之后,您需要使用show()函數顯示隱藏的td。 所以它就像:
$("#tableID th:first-child, #tableID th:last-child, #tableID td:first-child, #tableID td:last-child").show();
要么
$("#tableID tr th:first-child, #tableID tr th:last-child, #tableID tr td:first-child, #tableID tr td:last-child").show();
因此,您無需刷新頁面。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.