Skip to content

Instantly share code, notes, and snippets.

@tgpfeiffer
Created December 29, 2014 14:00
Show Gist options
  • Save tgpfeiffer/f2512a3fa932b1434ad0 to your computer and use it in GitHub Desktop.
Save tgpfeiffer/f2512a3fa932b1434ad0 to your computer and use it in GitHub Desktop.
Add QR codes to each link
<!-- paste this into the head element of an HTML file to append QR codes to each link -->
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("a").each(function(idx, item){
var a = $(item);
var href=a.attr("href");
a.qrcode({
text: href,
width: 300,
height: 300,
render: "canvas"
});
});
});
</script>
<style type="text/css">
canvas {
width: 2cm;
height: 2cm;
margin-left: .2cm;
margin-right: .2cm;
margin-top: .2cm;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment