jquery .html不包含html元素的最后更新值。 [英] jquery .html does not include the last upadated values of html elements.

查看:60
本文介绍了jquery .html不包含html元素的最后更新值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我试图在jquery的帮助下打印div内容。

但它不打印最新的对HTML元素进行的更改只打印了服务器端php通过ajax和jason最初返回的值和html元素。



换句话说,我首先动态填充reservediv,然后我应用其他jquery脚本来更新那些动态创建的html元素值,我可以在屏幕上看到我的结果,但是当我打印打印功能打印时,只打印服务器初始返回的旧值而不是屏幕上的新值





我将非常感谢帮助。



非常感谢提前。







代码如下。



Dear friends,

I am trying to print the divs content with the help of jquery.
But its not printing the latest changes done to the HTML elements its only printing the values and html elements those are initially returned by server side php via ajax and jason.

In other words I am dynamically populating the reservediv at first, then I apply other jquery script to update those dynamically created html elements values and I can see my results on screen, but when I call the print function to take a print its printing only the old values inititally returned by the server not the new values on the screen


I would appreciate the help.

Many thanks in advance.



the code is as follows.

<div id="reservediv" class="divmargin" style="display: none;">


<input type="submit" value="Update" id="reserveupdate" style="display: none;" />
<input type="button" value="Print" onclick="PrintElem('#reservediv')" class="btnprnt"  />
<input type="button" value="Save" class="btnprnt" id="savereserve"/>
<div id="resultsaving" > </div>
<div id="reserveaccountbtn"style="display: none;">
<input type="submit" value="RESERVE-XXXXXX8751"  class="bankmovementsbtn" id="btnreserve" style="display: none;">
<input type="text" value="" id="reserveaccounttext" class="bankmovementsbtn"style="display: none;">

<div id="openingbaldiv" class="divopening">
<input type ="button" value="Beginning   Balance" class="reconfields" id="openingbalbutton"/>
<input type="text" value="0" class="reconfields" id="openingbaltext" >
</div>
<div id="reconcilediv" class="divreconcile">
<input type ="button" value="Ending  Balance" class="reconfields" id="closingbalbutton"/>
<input type="text" value="" id="closingbaltext"  class="reconfields">
</div>

<div id="clearedbaldiv" class="divclearedbal">
<input type ="button" value="Cleared   Balance" class="reconfields" id="clearedbalbutton"/>
<input type="text" value="" id="clearedbaltext" class="reconfields" >
</div>

<div id="differencebaldiv" class="divdifferencebal">
<input type ="button" value="Difference" class="reconfields" id="differencebalbutton"/>
<input type="text" value="" id="differencebaltext"  class="reconfields">
</div>

<input type ="button" value="Check All" id ="selectchbx" class = "update" /> 
<input type ="button" value="Uncheck  All" id ="selectunchbx" class = "update" /> 
<input type ="button" value="Calculate" id ="reconcilereserve" class = "update" /> 





通过jquery打印的代码





Code to make print via jquery

<script type="text/javascript">
<!--
    function PrintElem(elem)
    {
        Popup($(elem).html());
    }

    function Popup(data) 
    {
        var mywindow = window.open('','Print Area','height=900 width=950');
		mywindow.document.write('<input type="text" id="messageprint1" value=" For  Firefox browser Press ctr+p to Print then close the Popup window, For Google Chrome just Press ctr+p to print" />');
        mywindow.document.write('<html><head><link REL="STYLESHEET" TYPE="text/css"  HREF="printout.css" media="print"> <link REL="STYLESHEET" TYPE="text/css" HREF="generatereports.css" media="screen">  <title>Print Area</title>');
        /*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />');
        mywindow.document.write('</head><body >');
        mywindow.document.write(data);
        mywindow.document.write('</body></html>');

        //mywindow.print();
        //mywindow.close();

        return true;
    } 
	
	</script>

推荐答案

(elem).html()) ;
}

function 弹出窗口(数据)
{
var mywindow = window .open(' '' 打印区域' ' height = 900 width = 950');
mywindow。 document .write(' < ;输入类型=文本id =messageprint1value =对于Firefox浏览器按ctr + p打印然后关闭弹出窗口,对于谷歌浏览器只需按ctr + p打印/>') ;
mywindow。 document .write(' < ; html>< head>< link REL =STYLESHEETTYPE =text / cssHREF =printout.cssmedia =print>< link REL =STYLESHEETTYPE =text / css HREF =generatereports.cssmedia =screen>< title> Print Area< / title>');
/ * 可选样式表* / // mywindow.document.write('< link rel =stylesheethref =main.csstype =text / css/>');
mywindow。 document .write(' < / head>< body>');
mywindow。 document .write(data);
mywindow。 document .write(' < ; /体>< / HTML>');

// mywindow.print();
// mywindow.close();

返回 true ;
}

< / script>
(elem).html()); } function Popup(data) { var mywindow = window.open('','Print Area','height=900 width=950'); mywindow.document.write('<input type="text" id="messageprint1" value=" For Firefox browser Press ctr+p to Print then close the Popup window, For Google Chrome just Press ctr+p to print" />'); mywindow.document.write('<html><head><link REL="STYLESHEET" TYPE="text/css" HREF="printout.css" media="print"> <link REL="STYLESHEET" TYPE="text/css" HREF="generatereports.css" media="screen"> <title>Print Area</title>'); /*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />'); mywindow.document.write('</head><body >'); mywindow.document.write(data); mywindow.document.write('</body></html>'); //mywindow.print(); //mywindow.close(); return true; } </script>


这对我现在有用






This is working for me now




(document).ready(function(){


(document).ready(function(){


这篇关于jquery .html不包含html元素的最后更新值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆