Skip to content

Instantly share code, notes, and snippets.

@shameerc
Created January 14, 2011 09:03
Show Gist options
  • Select an option

  • Save shameerc/779384 to your computer and use it in GitHub Desktop.

Select an option

Save shameerc/779384 to your computer and use it in GitHub Desktop.
jQuery code to generate qr code for links
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
(function($){
$.fn.qr = function(){
var url = $(this).attr('href');
var size= 4;
return 'http://qrcode.kaywa.com/img.php?s='+size+'&d='+url;
};
})(jQuery);
$(document).ready(function(){
$('.qr').hover(function(){
var qrcode = $(this).qr();
$('#qrimg').html('<img src="'+qrcode+'">');
})
$('.qr').mouseout(function(){
$('#qrimg').html('');
})
})
</script>
</head>
<body>
<a href="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" class="qr">JQuery</a>
<br/><br/><br/>
<a href="http://code.google.com/apis/chart/docs/gallery/qr_codes.html" class="qr">JQuery</a>
<div id="qrimg"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment