This commit is contained in:
Sam Thorogood 2017-01-23 09:20:48 +11:00
Родитель 64cb2a5eec
Коммит 7e49e8d34e
1 изменённых файлов: 11 добавлений и 2 удалений

Просмотреть файл

@ -8,16 +8,21 @@
<body>
<p>
Enter a value and submit the form. The close event will be fired and the value of the text box will be alerted.
Enter a value and submit the form. The close event will be fired and the <code>returnValue</code> of the dialog will be alerted.
</p>
<dialog>
<form method="dialog">
<input type="text" placeholder="Enter value" />
<input type="reset" value="Reset" />
<input type="submit" value="Stuff" />
<input type="submit" value="Done" />
<button type="submit" value="Button Value Is Different Than Text">Button Submit</button>
<button value="Regular Button Value">Button</button>
</form>
</dialog>
<button id="show">Show Dialog</button>
<script>
@ -27,7 +32,11 @@ dialog.showModal();
dialog.addEventListener('close', function() {
var valueEl = dialog.querySelector('input[type="text"]');
alert(valueEl.value);
alert(dialog.returnValue);
});
show.addEventListener('click', function() {
dialog.showModal();
});
</script>