Adding css file with jquery

I am creating a popupwindow and I want to add a css file to that popupwindow below is the code for popupwindow. I have a javascript with creates a popupwindow. 

<a href="popupwindowcontent.xhtml" title="Print" class="popupwindow">PopUp</a>
 
Now I want to add a css file to this popupwindow. I tried something like 

$('.popupwindow').append('<link rel="stylesheet" href="css/nav.css" type="text/css" />');


 $
('head').append('<link rel="stylesheet" href="css/nav.css" type="text/css" />');
 

Comments