我讀一個HTML模板,並將其添加到div的(我已經設置RUNAT =「服務器」)從服務器端代碼後面。這完美地呈現並在頁面上顯示HTML。現在,我更改客戶端呈現的HTML內的文本,並希望讀取服務器端的更新文本(div內的完整HTML)以更新模板。所以我已經採取了一個隱藏的領域,並保存點擊保存按鈕這樣的div更新的HTML。閱讀DIV內容USIG的jQuery跳過HTML,頭部和身體標記
$('#btnSaveTemplate').click(function() {
$('#UpdatedEmailTemplate').val($('#divEmailBody').html());
});
HTML模板:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<p>
<strong><u>Database Decommission Notice – IMPORTANT NOTIFICATION</u></strong>
</p>
<p>
<strong>FOLLOWING DATABASE(S) ARE SCHEDULED TO BE DECOMMISSIONED in 4 WEEKS from {SentDate};</strong>
</p>
<p>
<strong>Why have you received this email?</strong>
</p>
<p>
You are receiving this email as because you are an ITAO/ITAO delegate/CSM/CSM-1/key technical contact for database(s) that are scheduled to be decommissioned by 30. Below are the applications you have been identified.
</p>
</body>
</html>
的問題是,當我嘗試在隱藏字段保存更改的HTML在保存點擊,它給了我喜歡的內容如下。 (這是$( '#divEmailBody')輸出。HTML()方法)
\n\n\n <title></title>\n\n\n <p>\n <strong>\n <img style=\"width: 744px; height: 141px;\" alt=\"\" src=\"http://nyccgdbb0004.us.db.com/images/emailImmediateActionRequired.png\" border=\"0\">\n </strong>\n </p>\n <p>\n <strong><u>Database Decommission Notice – IMPORTANT NOTIFICATION</u></strong>\n </p>\n <p align=\"center\" class=\"MsoNormal\" style=\"margin: 0in 0.5in 6pt 0in; text-align: center;\">\n <b>\n <i>\n <u>\n <span lang=\"EN-GB\" style=\"color: rgb(192, 0, 0); font-size: 14pt;\">Do not ignore this message</span>\n </u>\n </i>\n </b>\n </p>\n <p>\n <strong>FOLLOWING DATABASE(S) ARE SCHEDULED TO BE DECOMMISSIONED in 4 WEEKS from 1/23/2017;</strong>\n </p>\n \n <p>\n <strong>Why have you received this email?</strong>\n </p>\n <p>\n <a title=\"\" class=\"editableText editable editable-pre-wrapped editable-click editable-unsaved\" href=\"#\" data-original-title=\"\" data-title=\"Update Text\" data-type=\"textarea\">You are receiving this email as because you are an ITAO/ITAO delegate/CSM/CSM-1/key technical contact for database(s) that are scheduled to be decommissioned by 30. Below are the applications you have been identified.test</a>\n </p>\n\n\n\n"
如何閱讀完整的HTML?
DOM中的UpdatedEmailTemplate和divEmailBody在哪裏? –
您的錯誤已經發生在您嘗試將_complete_ HTML文檔填充到div中的位置。這當然是無效的HTML,所以瀏覽器會放棄在這種情況下無法理解的元素。 – CBroe