Print a div content using Jquery

前端 未结 13 2232
栀梦
栀梦 2020-11-30 05:22

I want to print the content of a div using jQuery. This question is already asked in SO, but I can\'t find the correct (working) answer.

This is is my HTML:

13条回答
  •  臣服心动
    2020-11-30 06:09

    Print only selected element on codepen

    HTML:

    
    
    
    

    JQuery:

    $('.js-print-link').on('click', function() {
      var printBlock = $(this).parents('.print').siblings('.print');
      printBlock.hide();
      window.print();
      printBlock.show();
    });
    

提交回复
热议问题