jeromeetienne / jquery-qrcode

qrcode generation standalone (doesn't depend on external services)
http://blog.jetienne.com/blog/2011/04/07/jquery-qrcode/
MIT License
4.84k stars 2.51k forks source link

Input text though input box, but creates multiple qr codes #97

Open pupsrash opened 7 years ago

pupsrash commented 7 years ago

Hi! I have the latest version. Date : 29/6/17

This is my Jquery

        $(".generatetext").click(function() {
            var x = document.getElementById("textdata").value;
            $('#output').qrcode(x);
        });

so this gets the input value of the user, and generates the qr code on click on a button (.generatetext). but every time i click "Genarate Button" it generates a new qr code in a new line, doesn't replace the existing one.

<canvas width="256" height="256"></canvas>-> on first click
<canvas width="256" height="256"></canvas>-> on second click
<canvas width="256" height="256"></canvas>-> on third click

it creates a list of qr codes. how do i solve this problem. i want just one qr code to be shown every time i click on Generate button

thanks

zhangyuhan2016 commented 6 years ago

Can be manually emptied $("#output").html("")

$(".generatetext").click(function() {
        var x = document.getElementById("textdata").value;
        $(‘#output’).html(‘’)
        $('#output').qrcode(x);
    });