Print DIV content by JQuery

前端 未结 6 853
无人共我
无人共我 2021-02-06 03:26

suppose i have many div\'s in my page but i want to print the content of specific div using jquery. i found there is a plugin for that.

jQuery Print Element

usin

6条回答
  •  梦如初夏
    2021-02-06 04:12

    your question doesn't sound as if you even tried it yourself, so i shouldn't even think of answering, but: if a hidden div can't be printed with that one line:

    $('SelectorToPrint').printElement();
    

    simply change it to:

    $('SelectorToPrint').show().printElement();
    

    which should make it work in all cases.

    for the rest, there's no solution. the plugin will open the print-dialog for you where the user has to choose his printer. you simply can't find out if a printer is attached with javascript (and you (almost) can't print without print-dialog - if you're thinking about that).

    NOTE:

    The $.browser object has been removed in version 1.9.x of jQuery making this library unsupported.

提交回复
热议问题