Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display a Modal on button click using Jquery

I want to display my Modal on button click. Below is my code.

<input type="button" id="button1" value="Button" onclick="myFunction()"/>
<div id="openModal" class="modalDialog">
    <div>
        <a href="#close" title="Close" class="close">X</a>
        <h2>
            Modal Box</h2>
        <p>
            Hello world</p>
    </div>
</div>

This is my unfinished script.

<script type="text/javascript">
    $(document).ready(function () { 

    });
</script>
like image 255
Amit Avatar asked Feb 09 '23 22:02

Amit


1 Answers

show openModal div on button1 click.

$('#button1').on('click', function() {
    $('#openModal').show();
});

No need of onclick="myFunction()" on button

like image 80
Tushar Avatar answered Feb 12 '23 11:02

Tushar