How to print debugging information in JavaScript (Jquery)

Source: Internet
Author: User
Tags add time

Each time alert is used to output information, the amount of information is small, and debugging is inconvenient. This method can better write js Code. Because Jquery is used more often, only the debugging method of Jquery is written, you can also add time before debugging information based on your preferences.

/**

* Print the JavaScript debugging information. Use absolute positioning to locate the location. Each printed message has a blank line.

*/

Function plInfo (obj ){
If ($ ("# show"). length = 0)
$ ("Body "). append ("<div id = \" show \ "style = \" position: fixed; left0px; top: 0px; width: 500px; line-height: 14px; font-size: 12px; color: #456; z-index: 200; \ "> debug info <br/> </div> ");
$ ("# Show"). append (obj + "<br/> ");
}

/**

* Print the JavaScript debugging information. Use absolute positioning to locate the position. The information printed each time is not empty and connected --

*/

Function plInfoNoBR (obj ){
If ($ ("# show"). length = 0)
$ ("Body "). append ("<div id = \" show \ "style = \" position: fixed; left0px; top: 0px; width: 500px; line-height: 14px; font-size: 12px; color: #456; z-index: 200; \ "> debug info <br/> </div> ");
$ ("# Show"). append (obj + "--");
}

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.