js打印样式没有了

KK攻城狮 2017-02-04 04:59:49
function bindData() {

//如果checkbox,radio,select>option的值有变化, 也绑定一下, 这里忽略button
$("input,select option").each(function () {
$(this).attr('value', $(this).val());
});

$("input[type='text']").each(function () {
$(this).html($(this).val());
});

// type=checkbox,type=radio 选中状态
$("input[type='checkbox'],input[type='radio']").each(function () {
if ($(this).attr('checked'))
$(this).attr('checked', true);
else
$(this).removeAttr('checked');
});

//select选中状态
$("select option").each(function () {
if ($(this).attr('selected'))
$(this).attr('selected', true);
else
$(this).removeAttr('selected');
});

// textarea
$("textarea").each(function () {
$(this).html($(this).val());
});
}
function printdiv(printpage) {

bindData();
var headstr = "<html><head><title></title></head><body>";
var footstr = "</body>";
var newstr = document.all.item(printpage).innerHTML;
var oldstr = document.body.innerHTML;
document.body.innerHTML = headstr + newstr + footstr;
window.print();
document.body.innerHTML = oldstr;

return false;
}
...全文
1401 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
是小菜吖 2019-09-30
  • 打赏
  • 举报
回复
这是啥意思啥意思
无涯大者 2017-02-08
  • 打赏
  • 举报
回复

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧