0
$(document).on("click", "#btnPrin9t", function(e) {
  // e.preventDefault();
  // e.stopPropagation();
  $("#table, #txtW, #txtAt").printThis({
    debug: false, // show the iframe for debugging
    importCSS: true, // import page CSS
    importStyle: true, // import style tags
    printContainer: true, // grab outer container as well as the contents of the selector
    loadCSS: "", // path to additional css file - use an array [] for multiple
    pageTitle: "", // add title to print page
    removeInline: true, // remove all inline styles from print elements
    printDelay: 0, // variable print delay; depending on complexity a higher value may be necessary
    base: true,
    header: "",
    footer: "<br>Total in Words:'"
    $('#txtWord').val()
    "'", // prefix to html
    formValues: true // preserve input/form values
  });
});

我想使用页脚打印输入框值。我可以使用打印单击,如第一行所示,但需要进行一些调整。我想在页脚中使用任何人都可以帮忙。

4

1 回答 1

0

为了在 javascript 中连接字符串,我们使用+

所以代替这个:

"<br>Total in Words:'"$('#txtWord').val()"'"

尝试:

"<br>Total in Words:'"+$('#txtWord').val()+"'"

所以你的代码将是这样的:

 $(document).on("click", "#btnPrin9t", function (e) {
   // e.preventDefault();
  // e.stopPropagation();
  $("#table, #txtW, #txtAt").printThis({
    debug: false, // show the iframe for debugging
    importCSS: true, // import page CSS
    importStyle: true, // import style tags
    printContainer: true, // grab outer container as well as the contents of the selector
    loadCSS: "", // path to additional css file - use an array [] for multiple
    pageTitle: "", // add title to print page
    removeInline: true, // remove all inline styles from print elements
    printDelay: 0, // variable print delay; depending on complexity a higher value may be necessary
    base: true,
    header: "",
    footer: "<br>Total in Words:'"+$('#txtWord').val()+"'", // prefix to html
    formValues: true            // preserve input/form values
  });
});
于 2018-03-27T06:14:33.183 回答