Append stylesheet link for printing triggered on jQuery click() event
<p>I have one css link on the head section that has <code>media='screen'</code> attribute, then I want to link the other css file that has <code>media='print'</code> attribute dynamically.</p>

<p>and I do this for the solution.</p>

<pre><code>$("div#alert").click(function(){
    $('head')
    .append("&lt;link rel='stylesheet' href='css/alert.css' media='print' /&gt;");
    window.print();
});
</code></pre>

<p>But.. When I ran that code, the output just printed based on the <code>media='screen'</code> css.</p>

<p>Then I try again with the same code, I clicked the div element and when the print dialog box appear, I clicked the cancel button, then I clicked the div element again.. then clicked the ok button this time.. the <code>media='print'</code> is working... So what do I have to do with the <code>window.print()</code>?</p>
