0
I have the following html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<dialog id="my-dialog"></dialog>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#my-dialog').showModal();
});
</script>
</body>
</html>
I can open the dialog with the following javascript:
document.getElementById("my-dialog").showModal();
But I couldn’t find a way to open the modal using jQuery, I’ve tried this:
$('#my-dialog').showModal();
But the following error returns to me:
Uncaught TypeError: $(...).showModal is not a function
There is a way to open a dialog using jQuery?
Looks like you didn’t put Jquey’s library before the code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
– Laércio Lopes
I have already imported the jQuery library before my javascript code. I even use some functions without any problem of the library before I try to open the dialog
– Diego Heusser