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;
        },
  • 相关阅读:
    黑白逆向编程课程笔记 8.静&动态地址&偏移
    黑白逆向编程课程笔记 7.CE使用(2)
    黑白逆向编程课程笔记 6.CE使用(1)
    传奇资源
    分布式——分布式发号器
    SpringBoot——属性注入
    SpringBoot——启动与自动配置类查找
    Mybatis——Spring事务实现
    SpringAOP——事务实现
    Linux——IO技术
  • 原文地址:https://www.cnblogs.com/yoututu/p/14241073.html
Copyright © 2011-2022 走看看