How to make multiple JQuery pop up , on hyperlinks click?

Datacrawler

I want to make a popup box (with text in it) come out when i click a hyperlink. I have 5 hyperlinks in my html. Here is the code :

<div class="four columns">
  <h4>
    <a id="OpenDialog" href="#" >Open dialog 1</a>
  </h4>
  <img src="one.jpg" />
  <div id="dialog" title="Dialog Title 1">dialog text 1</div>
</div>
<div class="four columns">
  <h4>
    <a id="OpenDialog" href="#" >Open dialog 2</a>
  </h4>
  <img src="two.jpg" />
  <div id="dialog" title="Dialog Title 2">dialog text 2</div>
</div>

I put this in my html as well :

   <script type="text/javascript">
    $(document).ready(function () {
        $("#OpenDialog").click(function () {
            $("#dialog").dialog({modal: true, height: 590, width: 1005 });
        });
    });
  </script>

and I also included this ready scripts :

  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

But the thing is that the pop up functions only in the first hyperlink.

eyettea

I would use jquery parent and children to get what you want. (jsfiddle: http://jsfiddle.net/pjVcR/2/)

<script>
$("a").click(function(event) {
  $(this).parent().parent().children(".dialog").dialog({
    close: function( e, ui ) {
      $(this).dialog('destroy');
    }
  });
});
</script>

In this case you would have to hide the .dialog divs in the beginning. Moreover, change the dialog container to have a class (and not an id) named "dialog". This way you will not have many divs with the same id, and your functionality will be there.

Here some references:

  1. http://api.jquery.com/parent/
  2. http://api.jquery.com/children/
  3. Getting the ID of the element that fired an event

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to have a alert pop-up after my click function (form JavaScripy&JQuery - homework projet)

From Dev

How to make hyperlinks line up right next to eachother with HTML

From Dev

How to make hyperlinks line up right next to eachother with HTML

From Dev

Xcode - How to make a pop up menu

From Dev

How to make this pop up layer in the middle of the page?

From Dev

How to make pop-up for error bootstrap?

From Dev

How to make a pop up button (Python)

From Dev

Qt Creator: Button Click Signal to make a window pop- up

From Dev

On click pop up not working

From Dev

How to open multiple pop-up windows?

From Dev

sum up multiple jquery click events

From Dev

How to call or pop up fragment upon button click

From Dev

How can I click the tab bar to pop up a modal xcode

From Dev

How to pop up a childwindow from another .xam file button click?

From Dev

How can I click the tab bar to pop up a modal xcode

From Dev

jquery button in pop up

From Java

How to make linear layout inside pop up view responsive?

From Dev

How can I make the documentation pop-up on hover in PyCharm?

From Dev

how to make pop up on left side of each icon in list view?

From Dev

how to make window.open pop up Modal?

From Dev

how to make pop-up image using css3?

From Dev

How would I make a message pop up after this form is submitted?

From Dev

How do is use the SetInterval function and the 'if' to make div's pop up?

From Dev

How to make a certain window pop up if a certain number is put in

From Dev

how to make an alert pop up before my script

From Dev

How to make new Office Communicator session pop up in Windows 7

From Dev

How can I make a Msgbox pop up over other application?

From Dev

how to make pop up on left side of each icon in list view?

From Dev

How to call a html page and make it as pop up window in JavaScript?

Related Related

  1. 1

    How to have a alert pop-up after my click function (form JavaScripy&JQuery - homework projet)

  2. 2

    How to make hyperlinks line up right next to eachother with HTML

  3. 3

    How to make hyperlinks line up right next to eachother with HTML

  4. 4

    Xcode - How to make a pop up menu

  5. 5

    How to make this pop up layer in the middle of the page?

  6. 6

    How to make pop-up for error bootstrap?

  7. 7

    How to make a pop up button (Python)

  8. 8

    Qt Creator: Button Click Signal to make a window pop- up

  9. 9

    On click pop up not working

  10. 10

    How to open multiple pop-up windows?

  11. 11

    sum up multiple jquery click events

  12. 12

    How to call or pop up fragment upon button click

  13. 13

    How can I click the tab bar to pop up a modal xcode

  14. 14

    How to pop up a childwindow from another .xam file button click?

  15. 15

    How can I click the tab bar to pop up a modal xcode

  16. 16

    jquery button in pop up

  17. 17

    How to make linear layout inside pop up view responsive?

  18. 18

    How can I make the documentation pop-up on hover in PyCharm?

  19. 19

    how to make pop up on left side of each icon in list view?

  20. 20

    how to make window.open pop up Modal?

  21. 21

    how to make pop-up image using css3?

  22. 22

    How would I make a message pop up after this form is submitted?

  23. 23

    How do is use the SetInterval function and the 'if' to make div's pop up?

  24. 24

    How to make a certain window pop up if a certain number is put in

  25. 25

    how to make an alert pop up before my script

  26. 26

    How to make new Office Communicator session pop up in Windows 7

  27. 27

    How can I make a Msgbox pop up over other application?

  28. 28

    how to make pop up on left side of each icon in list view?

  29. 29

    How to call a html page and make it as pop up window in JavaScript?

HotTag

Archive