Simple implementation of adding HTML text content to div with jquery _jquery

Source: Internet
Author: User

Foreground code:

<link href= "Http://www.jb51.net/Content/themes/base/jquery-ui.css" rel= "
stylesheet" type= "Text/css"/> <script src= "Http://www.jb51.net/Scripts/jquery-1.4.4.min.js" type= "Text/javascript" ></script>
<script src= "Http://www.jb51.net/Scripts/jquery-ui.js" type= "Text/javascript" ></script>
function Poeviewexcel () {
  $.ajax (
  {
   URL: "Send/index",
   type: "Post",
   success:function (data) {
    var divshow = $ ("#showInfo2");
    Divshow.text ("");//empty data
    divshow.append; Add HTML content, you cannot use text or Val
    divshow.dialog ({
     title: "Bulk SMS System",
     height:250,
     width:580
    });

   }
  }
  );
  return false;
 }
<a href= "#" onclick= "return Poeviewexcel ()" > Preview Data </a> 
<div id= "Divpreview" style= "Display:none" >  
<text id= "ShowInfo2" ></text> 
</div>

Background (main):

 public string Getimportreport () {DataTable dt = this.
   Importexcel ();
   string content = String.Empty; Content = @ "<table width= ' border= ' 0 ' cellspacing= ' 0 ' cellpadding= ' 0 ' bgcolor= ' #D2D2D2 ' >" + "<tr Bgcolo R= ' #336699 ' > ' + ' <td align= ' center ' ><strong> serial number </strong></td> ' + ' <td align= ' cent Er ' ><strong> target mobile number </strong></td> ' + ' <td align= ' center ' ><strong> Send content </strong
   ></td> "+" </tr> "; for (int i = 0; i < dt. Rows.Count;  i++) {content + = "<tr>" + "<td width= ' align= ' center ' >" + i.tostring () + "</td>" + " <TD width= ' align= ' center ' > ' + dt. Rows[i][0]. ToString () + "</td>" + "<td width= ' >" + dt. ROWS[I][1].
   ToString () + "</td>" + "</tr>";
   Content + = "</table>";
  return content; }

Description

Divshow.append (data); Add HTML content, do not use text or Val

Of course, after (), the information will be continuously appended to the Div.

If you use text: Displays the loaded textual content;

If you use Val: Click on the link for the first time empty window, then click to appear data display,

The above article with jquery to add HTML text content in the Div is a simple implementation of the small series to share all the content, hope to give you a reference, but also hope that we support cloud habitat community.

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.