JQ use append to add HTML text and then delete the HTML text

Source: Internet
Author: User

Because the code in the project is too much in the way, it simplifies the code, only the description, not the code, but the method works.

Omit HTML code ... <div id= "Leftmenu" ></div> <!--for storing append HTML container--><input type= "button" onclick= "C Learhtmlfun () "/> <!--Remove the contents of the Append HTML--><script type=" Text/javascript ">var $html =" ";//global variable for storing HTML text objects  $ (function () {var strhtml = "<ul>";   strHTML + = "<li>aaa</li>";  ..... strhtml + = "</ul>";  $html = $ ("" + strHTML + "); This step is critical, as shown in Figure 1:firebug using the Console.info ($html) object | I test without "" will have a problem, not clear why $ ("#leftMenu"). Append ($html);         Append data using append});//Delete the contents of the appended HTML Clearhtmlfun = function () {$html. Remove (); Because the object is stored previously, you can use. Remove (), otherwise firebug will report. Remove () is not a function= return to see the one in Figure 1.}</script>

Figure 1:

JQ use append to add HTML text and then delete the HTML text

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.