When using JS to print the local page, encountered the user's new input content can not be printed out, after observation, I found that I used the JS printing method is to read the page source code, and user input content if not write it to the page source code, is not printed, the following is my solution:
Gets the label itself JQuery.fn.outerHTML = function (s) { return (s)? This.before (s). Remove (): $ ("<Hill_man>"). Append ( This.eq (0). Clone ()). html ();}; String.prototype.contains = function (str) { return This.indexof (str) >-1? true:false;};/ /save user Input function Saveuserinput () { $ ("Input[type=text]"). each (function () { $ (the). Bind ("Change", function ( { var old = $ (this). outerHTML (); var GHF = $ (this). Val (); var newstr = ""; if (Old.contains ("value")) { newstr = old.replace (/value= "*"/, "value=" "+ GHF +" ' "); } else { newstr = old.replace (/type= "text"/, "type= ' text ' value= '" + GHF + "'"); } $ (this). outerHTML (NEWSTR); });
When used, you only need to call the Saveuserinput method when the page is loaded, so that when the contents of the text box change, the new content will be written to the source code so that the text entered by the user can be printed out.
JS Print Save user input content