我想写一个java脚本:
<div>标记的内容时脚本的任何想法?
我知道如何导航到元素但不知道如何复制内容.
div的内容将是这样的
<div id="validationDiv">
<div id="ctl00_Main_OTClaim1_valControls" class="errorpanel" style="color:Red;">
<ul><li>Approver Name - required field.</li><li>Week Commencing Date - required field.</li><li>Summary of Hours Worked must be completed.</li><li>At least one item must be claimed to proceed.</li></ul>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
其中valadation div包含我要复制到新窗口的内容
干杯
window.onload = function() {
var el = document.getElementById("ctl00_Main_OTClaim1_valControls");
var html = "";
if (el) {
html = document.getElementById("ctl00_Main_OTClaim1_valControls").innerHTML;
var xopen = window.open("about:blank");
xopen.document.write(html);
}
}
Run Code Online (Sandbox Code Playgroud)
--update
window.onload = function() {
var el = document.getElementById("ctl00_Main_OTClaim1_valControls"); //the element you want expanded
var html = "";
if (el) {
html = el.innerHTML;
var xopen = window.open("about:blank");
xopen.document.write(html);
}
}
Run Code Online (Sandbox Code Playgroud)