JsBarcode - 生成条形码并打印出来
作者:互联网
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/JsBarcode.all.min.js"></script>
<script src="js/jQuery.print.js"></script>
</head>
<body>
<input id="code" type="text" placeholder="请输入条形码"><button id="save">生成条形码</button>
<br>
<div id="PrintSection">
<img id="test">
</div>
<br>
<button id="print">打印</button>
<script>
$(function () {
// 生成条形码
$("#save").click(function () {
var requestNo = $("#code").val();
if (requestNo == "") {
return false;
} else {
$("#test").JsBarcode(requestNo);
}
})
// 打印条形码
$("#print").click(function () {
$("#PrintSection").print({
globalStyles: true,
mediaPrint: false,
stylesheet: null,
noPrintSelector: ".btncontainer",
iframe: true,
append: null,
prepend: null,
manuallyCopyFormValues: true,
deferred: $.Deferred(),
timeout: 750,
title: null,
doctype: '<!doctype html>'
});
})
})
</script>
</body>
</html>
标签:并打印,条形码,false,JsBarcode,function,requestNo,null,true 来源: https://blog.csdn.net/tian_tian_gong/article/details/88824712