some content

Open Now I want to use j...">

Create popup content using jquery

Say I have this code

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

Now I want to use javascript / jquery to create a popup, the contents of the window are the contents of the test paragraph when test-link clicked. How can I do that?

+4
source share
4 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(); } 
+9
source

You can do this using jQuery UI (dialog) (see examples in the reference documentation).

+3
source
+1
source

Use the jQuery UI dialog to display a popup.

For your html:

 $(function() { $("#test-link").click(function() { $("#test").dialog({ resizable: true, modal: false, draggable: true }); }); }); 

If you do not want to use the jQuery UI dialog, you can use ThickBox .

0
source

Source: https://habr.com/ru/post/1313862/


All Articles