繁体   English   中英

如何从html删除标签样式

[英]How to remove tag style from html

如何从HTML内部数据变量中删除style =“”?

function printCalendar($scope) {
    $scope.print = function(){
        var data = $('.fc-content').html();
        var mywindow = window.open('', 'my div', '');
        mywindow.document.write('<html><head><link rel="stylesheet" href="css/printcalendar.css"/></head><body >');
        mywindow.document.write(data);
        mywindow.document.write('</body></html>');
        mywindow.document.close();
        mywindow.focus();
        mywindow.print();
    }
}

您应该通过克隆 fc-content来做到这一点-这样,您就可以使用jQuery执行操作:

var $clone = $('.fc-content').clone(); // Clone the element
$clone.find("[style]") // Find the elements with style attributes
    .removeAttr("style") // Remove the attribute entirely
var data = .html(); // Now grab the clone's HTML

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM