How to Use js to generate UUID when using jquery?

Source: Internet
Author: User
Source: http://www.broofa.com/2008/09/javascript-uuid-function/

1. Code: http://www.broofa.com/Tools/Math.uuid.js

2. Test: http://www.broofa.com/Tools/Math.uuid.htm

----------------------------------------------------

Generate UUID in JS

Call method: see the JS description.

Math. UUID (); commonly used

Math. uuidfast (); you can delete it if you don't need it.

Math. uuidcompact (); you can delete it if you don't need it.

 

HTML code
  1. <HTML>
  2. <Head>
  3. <Title> UUID test </title>
  4. <SCRIPT src = "UUID. js"> </SCRIPT>
  5. <SCRIPT src = "jquery-1.7.2.min.js"> </SCRIPT>
  6. <SCRIPT>
  7. $ (Function (){
  8. VaR begin = new date ();
  9. For (VAR I = 0; I <1000; I ++ ){
  10. // Math. UUID (); // operation 1000 times, 47 Ms
  11. // Math. uuidfast (); // operation 1000 times, 31 Ms
  12. // Math. uuidcompact (); // 1000 operations, 8-94 milliseconds
  13. // $ ("Body"). append (math. UUID () + '<br/> ');
  14. $ ("Body"). append (math. UUID () + '<br/> ');
  15. }
  16. VaR end = new date ();
  17. Alert (end. gettime ()-begin. gettime (); // 1000 702 milliseconds
  18. });
  19. </SCRIPT>
  20. </Head>
  21. <Body>
  22. UUID test <br/>
  23. </Body>

 

 

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.