Print window is not working in ASP.NET MVC using jQuery -


i have opened print window in tab opened have given button no action performed button instead have click on action new opened print window i.e action i.e print , cancel or close window. if perform 1 of above action on new opened print window button working correctly prsent in print button present in printpreview window 2 button

  1. print
  2. back

    <input  id="printmasterlist" value="print"/>            <input  value="back" onclick="window.location.href='@url.action("index")'"/> 

and printpreview.cshtml page print button is

the div #masterlistprintpreview present on printpreview.cshtml page

<div class="span8" id="masterlistprintpreview" style="">  $("#printmasterlist").click(function () {            var divcontents = $("#masterlistprintpreview").html();     printwindow = window.open('', '','');     printwindow.document.write('<html><head><title>orders</title>');     printwindow.document.write('</head><body >');     printwindow.document.write(divcontents);     printwindow.document.write('</body></html>');     printwindow.document.close();     printwindow.print();     printwindow.document.close(); }); 

so need if click on print, print open , didn't perform action in print window if click on button should work.

any thoughts