O
O
olifem2017-07-19 17:16:43
JavaScript
olifem, 2017-07-19 17:16:43

How to make multiple modal windows?

There is such a design

<script>
    $(document).ready(function(){
        PopUpHide();
    });

    function PopUpShow(){
        $("#popup").show();
    }

    function PopUpHide(){
        $("#popup").hide();
    }
</script>

And such
<div id="popup" name="Users">
</div>

<div id="popup" name="Groups">
</div>

<a class="del" href="javascript:PopUpHide()" onclick="fync();" title="Close users">X</a>	
  <a class="del" href="javascript:PopUpHide()" onclick="fync();" title="Close groups">X</a>

And 2 buttons respectively
How to make multiple popups?
I think everything is very simple and when calling the function you need to pass an identifier, but I don’t know how to do it.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Yarkov, 2017-07-19
@olifem

$(document).ready(function(){
        PopUpHide('popup1');
    });

    function PopUpShow(id){
        $(`#${id}`).show();
    }

    function PopUpHide(id){
        $(`#${id}`).hide();
    }

<div id="popup1" name="Users">
</div>

<div id="popup2" name="Groups">
</div>

M
Mikhail Zakharov, 2017-07-19
@cashalot

Modals should open by class. You can't have more than one element with the same id! This is an id and must be unique. This html will not be valid.
And in the button, you can pass a parameter by which it will determine which window it should open. For example, in the data attribute.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question