Hey if you want to add print button for selected matter under DIV section in your WordPress. So follow simple steps and make it on your WordPress website.
How To Do
First of all add button and create DIV box. Then add id in button and div part.
Example:-
Button – <button id=”splPrint“>Print </button>
DIV – <div id=”spldivPrint“> Some-text </div>
Then paste given javascript code in your WordPress’s Theme
window.onload = function() { function print() { document.body.innerHTML; var n = document.getElementById("spldivPrint").innerHTML, e = window.open(); e.document.open(), e.document.write(n), e.window.print(), e.document.close();} document.getElementById("splPrint").onclick = print; }
or
window.addEventListener("load", function(){ document.getElementById("splPrint").onclick = function(){document.body.innerHTML; var n = document.getElementById("spldivPrint").innerHTML, e = window.open(); e.document.open(), e.document.write(n), e.window.print(), e.document.close();}; });
Hope this code will work on your WordPress Theme. If you have any other type help so contact me via contact us section.