Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

creating popup content with jquery

Let's say i have this code

<p id="test">
  some content
<p>
<a href="#" id="test-link">Open</a>

Now i want -using javascript/jquery- to create a popup window, the window content is the content of test paragraph, when test-link is clicked. How could this be done?

like image 553
Ibrahim Hussein Avatar asked Dec 10 '22 15:12

Ibrahim Hussein


1 Answers

  <a href="javascript:popup();"  id="test-link">Open</a>

function popup()
{
  var generator=window.open('','name','height=400,width=500');

  generator.document.write('<html><head><title>Popup</title>');
  generator.document.write($("#test").html());
  generator.document.write('</body></html>');
  generator.document.close();
}
like image 192
Pranay Rana Avatar answered Dec 15 '22 00:12

Pranay Rana