gpt4 book ai didi

当表具有 ID 或类时,JQuery 将表导出到 Excel 时出错

转载 作者:行者123 更新时间:2023-12-01 01:34:11 25 4
gpt4 key购买 nike

如果<table>,我可以使用jquery导出HTML表没有 ID 或类别:

http://jsfiddle.net/n9XRx/

但是,如果我的表有 ID 或类属性,则以下 jquery 会在一个单元格中踢出一串 html 以进行 Excel 处理:

$( "#clickExcel" ).click(function() {  
var dtltbl = $('#dtltbl').html();
window.open('data:application/vnd.ms-excel,' + $('#dtltbl').html());
});

我可以通过删除表类和 ID 来解决这个问题,但这并不理想。有人有解决办法吗?

最佳答案

我和你遇到了同样的问题,已经解决了:

$("#btnExport").click(function (e) {
window.open('data:application/vnd.ms-excel,' +'<table>' +$("#YourTableId").html()+ '</table>');
e.preventDefault();
});

希望有帮助

关于当表具有 ID 或类时,JQuery 将表导出到 Excel 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21322261/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com