jQuery生成二维码
2015-07-02 11:33
639 查看
jQuery.qrcode
实例下载
jQuery生成二维码实例下载
[/code]
//中文问题
[/code]
关于生成的选项
Thesyntaxisverysimple.Justuse
toappendanewgeneratedHTMLelementrepresentingtheQRcodetotheselectedelements.Iftheselectedelementalreadyisa
thentheQRcodeisdrawnontoit.
Theavailableoptionsandtheirdefaultvaluesare:
实例下载
<html>
<head>
<scripttype="text/javascript"src="jquery-1.3.2.min.js"></script>
<scripttype="text/javascript"src="jquery.qrcode-0.12.0.min.js"></script>
<scripttype="text/javascript">
$(function(){
$("#bcTarget").barcode("123456789","codabar",{barWidth:2,barHeight:80});
//二维码
$("#two").qrcode({
"render":"div",
"size":100,
"color":"#3a3",
"text":"http://liubo.club"
});
});
</script>
</head>
<body>
二维码
<br>
<divid="two"></div>
</body>
</html>
[/code]
<html>
<head>
<scripttype="text/javascript"src="jquery-1.3.2.min.js"></script>
<scripttype="text/javascript"src="jquery-barcode-2.0.1.js"></script>
<scripttype="text/javascript"src="jquery.qrcode-0.12.0.min.js"></script>
<scripttype="text/javascript">
//中文问题
functiontoUtf8(str){
varout,i,len,c;
out="";
len=str.length;
for(i=0;i<len;i++){
c=str.charCodeAt(i);
if((c>=0x0001)&&(c<=0x007F)){
out+=str.charAt(i);
}elseif(c>0x07FF){
out+=String.fromCharCode(0xE0|((c>>12)&0x0F));
out+=String.fromCharCode(0x80|((c>>6)&0x3F));
out+=String.fromCharCode(0x80|((c>>0)&0x3F));
}else{
out+=String.fromCharCode(0xC0|((c>>6)&0x1F));
out+=String.fromCharCode(0x80|((c>>0)&0x3F));
}
}
returnout;
}
$(function(){
$("#bcTarget").barcode("123456789","codabar",{barWidth:2,barHeight:80});
//二维码
$("#two").qrcode({
"render":"div",
"size":100,
"color":"#3a3",
"text":"http://liubo.club"
});
//生成条形码
$("#genid").click(function(){
varcode=$("#orgcode").val();
$("#mycode").barcode(code,"codabar",{barWidth:2,barHeight:80});
});
//生成二维码
$("#twobtn").click(function(){
varqrcode=$("#twotext").val();
qrcode=toUtf8(qrcode);
$("#twoimg").qrcode({
"render":"div",
"size":100,
"color":"#3a3",
"text":qrcode
});
});
});
</script>
</head>
<body>
首先自动生成条形码123456789
<divid="bcTarget"></div>
输入要生成条形码的数字
<inputtype="text"id="orgcode">
<divid="mycode"></div>
<inputtype="button"value="生成条形码"id="genid"/>
<br>
<p>
liubo.club二维码
<br>
<divid="two"></div>
<p>
输入内容生成二维码
<inputtype="text"id="twotext"/>
<br>
<inputtype="button"value="生成二维码"id="twobtn"/>
<divid="twoimg"></div>
</body>
</html>
[/code]
关于生成的选项
Usage
Thesyntaxisverysimple.Justuse$(selector).qrcode(options);
toappendanewgeneratedHTMLelementrepresentingtheQRcodetotheselectedelements.Iftheselectedelementalreadyisa
canvaselement,
thentheQRcodeisdrawnontoit.
Options
Theavailableoptionsandtheirdefaultvaluesare:{
//rendermethod:'canvas','image'or'div'render:'canvas',
//versionrangesomewherein1..40minVersion:1,
maxVersion:40,
//errorcorrectionlevel:'L','M','Q'or'H'ecLevel:'L',
//offsetinpixelifdrawnontoexistingcanvasleft:0,
top:0,
//sizeinpixelsize:200,
//codecolororimageelementfill:'#000',
//backgroundcolororimageelement,nullfortransparentbackgroundbackground:null,
//contenttext:'notext',
//cornerradiusrelativetomodulewidth:0.0..0.5radius:0,
//quietzoneinmodulesquiet:0,
//modes//0:normal//1:labelstrip//2:labelbox//3:imagestrip//4:imageboxmode:0,
mSize:0.1,
mPosX:0.5,
mPosY:0.5,
label:'nolabel',
fontname:'sans',
fontcolor:'#000',
image:null}
相关文章推荐
- js--下拉列表选中(js和jquery两种方法 )
- 生成条形码_jQuery_barcode
- JQuery 遍历子元素+ each函数的跳出+提取字符串中的数字
- jquery attr和css属性
- jQuery入门:选择元素 Selecting Elements
- Jquery简单整理
- 『jQuery』.html(),.text()和.val()的使用
- jQuery选择器
- 深入学习理解jQuery中的extend方法以及JavaScript中对象的复制
- jquery获取所有选中的checkbox
- jquery返回顶部
- struts2+jquery+ajax的使用
- 10款基于jquery的web前端特效及源码下载
- jQuery切换所有复选框选中状态的方法
- jQuery移出style
- jQuery+toggle
- jQuery中的end()方法
- springMVC与jquery结合使用完整例子
- jquery遍历之children()与find()的区别
- jquery遍历table的tr获取td的值