用jQuery向div中添加Html文本內(nèi)容的簡單實(shí)現(xiàn)
前臺(tái)代碼:
<link href="http://www.dbjr.com.cn/Content/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" /> <script src="http://www.dbjr.com.cn/Scripts/jquery-1.4.4.min.js" type="text/javascript"></script> <script src="http://www.dbjr.com.cn/Scripts/jquery-ui.js" type="text/javascript"></script>
function PoeviewExcel() { $.ajax( { url: "send/index", type: "post", success: function (data) { var divshow = $("#showInfo2"); divshow.text("");// 清空數(shù)據(jù) divshow.append(data); // 添加Html內(nèi)容,不能用Text 或 Val divshow.dialog({ title: "短信群發(fā)系統(tǒng)", height: 250, width: 580 }); } } ); return false; }
<a href="#" onclick="return PoeviewExcel()">預(yù)覽數(shù)據(jù)</a> <div id="divPreview" style="display: none"> <text id="showInfo2"></text> </div>
后臺(tái)(主要):
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>序號(hào)</strong></td>" + " <td align='center'><strong>目標(biāo)手機(jī)號(hào)</strong></td>" + " <td align='center'><strong>發(fā)送內(nèi)容</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內(nèi)容,不能用Text 或 Val
當(dāng)然用 after();會(huì)在該div中不斷追加信息。
如果用Text:顯示加載的文本內(nèi)容;
如果用Val:點(diǎn)擊鏈接第一次為空窗口,再點(diǎn)擊才出現(xiàn)數(shù)據(jù)顯示、
以上這篇用jQuery向div中添加Html文本內(nèi)容的簡單實(shí)現(xiàn)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Jqyery中同等與js中windows.onload的應(yīng)用
我們知道,在javascript中用來執(zhí)行頁面加載中的操作時(shí)候,我們會(huì)使用windows.onload=function(){}或者windows.onload=函數(shù)名(),也可以在body中調(diào)用onload事件調(diào)用方法即可,在jQuery中也有相當(dāng)?shù)拇a2011-05-05jQuery Validation PlugIn的使用方法詳解
這篇文章主要介紹了jQuery Validation PlugIn的使用方法,需要的朋友可以參考下2015-12-12jQuery 1.9.1源碼分析系列(十五)之動(dòng)畫處理
這篇文章主要介紹了jQuery 1.9.1源碼分析系列(十五)之動(dòng)畫處理 的相關(guān)資料,需要的朋友可以參考下2015-12-12Bootstrap table中toolbar新增條件查詢及refresh參數(shù)使用方法
這篇文章主要介紹了Bootstrap table中toolbar新增條件查詢及refresh參數(shù)使用方法,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-05-05jquery.onoff實(shí)現(xiàn)簡單的開關(guān)按鈕功能(推薦)
這篇文章主要介紹了jquery.onoff實(shí)現(xiàn)簡單的開關(guān)按鈕功能,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-05-05