H5 development app to generate two-dimensional code online

Source: Internet
Author: User

h5 generate QR codes online via jquery and QRCode

First we need to download a qrcode.js file and then introduce jquery and QRCode files in turn.

1. Create an input box for demonstration use:

<id= "text"  type= "text"  value= "http// Www.baidu.com "  style=" width:80%"/>

2. Create a div to place the two-dimensional code image (the div ID is defined as "QRCode"):

<id= "QRCode"  style= "width:100px; height:100px; margin-top:15px;" ></ Div >

3. Insert JS Code:

1 varQRCode =NewQRCode (document.getElementById ("QRCode"), {2width:100,3height:1004 });5 6 functionMakecode () {7     varEltext = document.getElementById ("text");8     9     if(!eltext.value) {TenAlert ("Input a text"); One Eltext.focus (); A         return; -     } -      the Qrcode.makecode (eltext.value); - } -  - Makecode (); +  -$ ("#text"). +On ("Blur",function () { A Makecode (); at     }). -On ("KeyDown",function(e) { -         if(E.keycode = = 13) { - Makecode (); -         } -     }); in</script

This allows you to generate two-dimensional code online!

Is our code, try to scan under the phone will not jump to Baidu home page.

H5 development app to generate two-dimensional code online

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.