console
$(function () {
$('.btn1').click(function() {
var qr = $('.qrcode'),
oUrl = $('.p1 input').val();
qr.empty().qrcode({
text: oUrl,
render: 'canvas',
width: 240,
height: 240,
background: '#fff',
foreground: '#000'
});
});
});
<div class="wrapper">
<h1>二维码生成器</h1>
<div class="qrcode"></div>
<p class="p1"><input type="text" placeholder="http://"></p>
<button class="btn1">立即生成二维码</button>
</div>
body,p,div,ol,ul,li,dl,dt,dd,h1,h2,h3,h4,h5,h6,form,input,iframe,nav {
margin: 0;
padding: 0;
}
body {
font: 16px Microsoft YaHei;
}
a {
text-decoration: none;
}
ol,ul {
list-style: none;
}
.wrapper {
width: 500px;
margin: 100px auto;
}
.wrapper h1 {
text-align: center;
color: #333;
margin: 30px auto;
font: 20px Microsoft YaHei;
}
.qrcode {
width: 240px;
height: 240px;
background: #fff;
padding: 20px;
border: 1px solid #ddd;
margin: 0 auto;
}
.p1 {
width: 100%;
margin: 30px auto;
text-align: center;
}
.p1 input {
outline: none;
width: 100%;
height: 38px;
border: 1px solid #ccc;
font-size: 16px;
border-radius: 3px;
box-sizing: border-box;
padding: 0 10px;
color: #666;
transition: .6s;
}
.p1 input:focus {
border: 1px solid #0ae;
}
.btn1 {
display: block;
width: 125px;
height: 40px;
background: #0ae;
font: 14px Microsoft YaHei;
margin: 20px auto 0 auto;
border-radius: 5px;
outline: none;
border: 0;
color: #fff;
cursor: pointer;
transition: .5s;
}
.btn1:hover {
background: #09d;
}