用jQuery向div中添加Html文本内容

简介: 前台代码:   function PoeviewExcel() { $.ajax( { url: "send/index", type: "post", success: f...

前台代码:

<link href="http://www.cnblogs.com/Content/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="http://www.cnblogs.com/Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="http://www.cnblogs.com/Scripts/jquery-ui.js" type="text/javascript"></script>

 

复制代码
    function PoeviewExcel() {
$.ajax(
{
url: "send/index",
type: "post",
success: function (data) {
var divshow = $("#showInfo2");
divshow.text("");// 清空数据
divshow.append(data); // 添加Html内容,不能用Text 或 Val
divshow.dialog({
title: "短信群发系统",
height: 250,
width: 580
});

}
}
);
return false;
}
复制代码
<a href="#" onclick="return PoeviewExcel()">预览数据</a>
<div id="divPreview" style="display: none">
<text id="showInfo2"></text>
</div>


后台(主要):

复制代码
        public string GetImportReport()
{
DataTable dt = this.ImportExcel();
string content = String.Empty;
content = @"<table width='550' border='0' cellspacing='0' cellpadding='0' bgcolor='#D2D2D2'>"
+ " <tr bgcolor='#336699'>"
+ " <td align='center'><strong>序号</strong></td>"
+ " <td align='center'><strong>目标手机号</strong></td>"
+ " <td align='center'><strong>发送内容</strong></td>"
+"</tr>";
for (int i = 0; i < dt.Rows.Count; i++)
{
content += "<tr>"
+ " <td width='50' align='center'>" + i.ToString()+"</td>"
+ " <td width='150' align='center'>" + dt.Rows[i][0].ToString() + "</td>"
+ " <td width='150' >" + dt.Rows[i][1].ToString() + "</td>"
+ " </tr>";
}
content += "</table>";
return content;
}
复制代码

说明:

divshow.append(data); // 添加Html内容,不能用Text 或 Val

当然用 after();会在该div中不断追加信息。

如果用Text:显示加载的文本内容;

如果用Val:点击链接第一次为空窗口,再点击才出现数据显示

如何联系我:【万里虎】www.bravetiger.cn 【QQ】3396726884 (咨询问题100元起,帮助解决问题500元起) 【博客】http://www.cnblogs.com/kenshinobiy/
目录
相关文章
|
1月前
html中div内容居中的方法使用弹性盒子居中
html中div内容居中的方法使用弹性盒子居中
9 0
|
2月前
|
JavaScript
jQuery遍历div,判断是否为空,为空时执行某个操作
jQuery遍历div,判断是否为空,为空时执行某个操作
9 0
|
2月前
|
前端开发 开发者 容器
|
29天前
|
JavaScript
用JQuery实现选中select里面的option显示对应的div
用JQuery实现选中select里面的option显示对应的div
|
22天前
|
前端开发 搜索推荐
【HTML专栏4】常用标签(标题、段落、换行、文本格式化、注释及特殊字符)
【HTML专栏4】常用标签(标题、段落、换行、文本格式化、注释及特殊字符)
18 0
|
26天前
|
前端开发 JavaScript
HTML深度解析:更改文本颜色
【4月更文挑战第1天】
43 0
HTML深度解析:更改文本颜色
|
2月前
|
JavaScript
jQuery选择器案例之——index.html
jQuery选择器案例之——index.html
9 1
|
2月前
|
JavaScript
jquery实现单击div切换背景,再次单击回到原来样式
jquery实现单击div切换背景,再次单击回到原来样式
9 0
|
2月前
HTML文本内容标签
HTML文本内容标签
|
2月前
编程笔记 html5&css&js 007 HTML文本:段落和格式
编程笔记 html5&css&js 007 HTML文本:段落和格式