zoukankan      html  css  js  c++  java
  • 解决原生打印输入值 打印时为空问题

    1.利用jquery

    2.

    bindData() {
          $("input,select option").each(function() {
            $(this).attr("value", $(this).val());
          });

          //搞定 type=checkbox,type=radio 选中状态
          $("input[type='checkbox'],input[type='radio']").each(function() {
            if ($(this).prop("checked")){
               $(this).attr("checked",true);
            }
            else{
              $(this).removeAttr("checked");
            } 
          });

          // 搞定select选中状态
          $("select option").each(function() {
            if ($(this).attr("selected")) $(this).attr("selected", true);
            else $(this).removeAttr("selected");
          });

          //搞定 textarea
          $("textarea").each(function() {
            $(this).html($(this).val());
          });
        },
     
     
    3.
    printContent() {
          this.bindData();
          const wpt = document.getElementById("panel");
          const newContent = wpt.innerHTML;
          const oldContent = document.body.innerHTML;
          document.body.innerHTML = newContent;
          document.getElementsByTagName("body")[0].style.zoom = 0.7;  //缩放
          window.print(); //打印方法
          window.location.reload();
          document.body.innerHTML = oldContent;
        },
  • 相关阅读:
    linux下开启防火墙,允许通过的端口
    linux下限定连接ip和端口
    centos7关闭防火墙
    linux下清空文件内容的3个命令
    yum安装软件包提示Error Downloading Packages解决方法
    Zabbix 监控服务介绍
    Redis 应用
    分布式中间件MyCat 使用
    DevOps Gitlab环境部署
    MySQL Atlas 读写分离软件介绍
  • 原文地址:https://www.cnblogs.com/yoututu/p/14241073.html
Copyright © 2011-2022 走看看