Blogger Information
Blog 55
fans 0
comment 0
visits 59339
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
jq 生成二维码
南鸢离梦的博客
Original
677 people have browsed it

// 引入jq qrcode

<script type="text/javascript" src="/static/js/jquery.qrcode.min.js"></script>

想显示二维码的地方

<div id="code"></div>

// 需要打印时,放出来

// <img id="image" src="" />
JS

$(document).ready(function(){

  1. var number = $("#number").val();
  2. $("#code").qrcode({
  3. render: "canvas", //table方式
  4. width: 235, //宽度
  5. height:235, //高度
  6. text: number //任意内容
  7. });

})
// 如果要打印(canvas 是动态生成不能直接打印,所以要赋值给img标签)

var img = document.getElementById(“image”); // get image element

var canvas = document.getElementsByTagName(“canvas”)[0]; // get canvas element

var div = document.getElementById(“code”);

div.style.display = ‘none’;

img.src = canvas.toDataURL();

下载地址http://www.jq22.com/jquery-info294

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post