我有一個帶有DIV元素的網頁。當用戶點擊「打印」時,我想打印該div的內容。請注意,我只想打印DIV的內容,而不是整個頁面。爲了嘗試這個,我決定使用JavaScript打開一個新窗口。然後我將把DIV的內容寫入新窗口。我的問題是,這可能與JQuery?如果是這樣,怎麼樣?目前,我嘗試以下:用JQuery將內容寫入新窗口
function printClick() {
var w = window.open();
var html = $("#divToPrintID").html();
// how do I write the html to the new window with JQuery?
}
這裏有一個類似的線程:http://stackoverflow.com/questions/1225558/jquery-new-window-with-content-from-modal- content-on-opener-page – orolo 2010-10-01 16:29:17