how to print an html element in jquery code example

Example 1: jquery print div

jQuery('#divId').print(/* options */);

jQuery.print('#divId'/*, options */);

jQuery('#divId').print({
    globalStyles : true,
    mediaPrint : false,
    stylesheet : null,
    noPrintSelector : '.no-print',
    iframe : true,
    append : null,
    prepend : null,
    manuallyCopyFormValues : true,
    deferred : jQuery.Deferred(),
    timeout : 750,
    title : null,
    doctype : '<!doctype html>'
});

/**
 * NB! The above samples will not run with pure jQuery
 * Methods jQuery.print / jQuery.fn.print are populated by third-party
 * plugin 
 * 
 * One should either download this plugin and host it along with
 * own project or to include it directly from CDN 
 * 
 * Use the link https://doersguild.github.io/jQuery.print/ to download the
 * plugin from Github or install it with npm (npm i --save jQuery.print)
 * 
 * Add this tag to your html template to include the plugin from CDN
 * <script src="https://cdn.jsdelivr.net/npm/jQuery.print@1/jQuery.print.min.js" async></script>
 * (be sure to paste it under the tag which loads jQuery)
 */

Example 2: print in jquery

window.print();