From 0ccebc7eb352eda4d26d0b876fea36f24f482eec Mon Sep 17 00:00:00 2001 From: MDN Date: Sat, 17 Apr 2021 00:11:36 +0000 Subject: [CRON] sync translated content --- .../creating_and_triggering_events/index.html | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 files/pl/orphaned/web/guide/events/creating_and_triggering_events/index.html (limited to 'files/pl/orphaned') diff --git a/files/pl/orphaned/web/guide/events/creating_and_triggering_events/index.html b/files/pl/orphaned/web/guide/events/creating_and_triggering_events/index.html new file mode 100644 index 0000000000..48b07b10ce --- /dev/null +++ b/files/pl/orphaned/web/guide/events/creating_and_triggering_events/index.html @@ -0,0 +1,35 @@ +--- +title: dispatchEvent - przykład +slug: orphaned/Web/Guide/Events/Creating_and_triggering_events +tags: + - DOM + - Dokumentacja_Gecko_DOM + - Gecko + - Wszystkie_kategorie +translation_of: Web/Guide/Events/Creating_and_triggering_events +translation_of_original: Web/Guide/Events/Event_dispatching_example +original_slug: Web/Guide/Events/Creating_and_triggering_events +--- +
+ {{ ApiRef() }}
+

Poniższy przykład przedstawia symulację kliknięcia w pole wyboru opartą o metody DOM. Możesz zobaczyć przykład w działaniu.

+
function simulateClick() {
+  var evt = document.createEvent("MouseEvents");
+  evt.initMouseEvent("click", true, true, window,
+    0, 0, 0, 0, 0, false, false, false, false, 0, null);
+  var cb = document.getElementById("checkbox");
+  var canceled = !cb.dispatchEvent(evt);
+  if(canceled) {
+    // metoda obsługi zdarzenia wywołała preventDefault
+    alert("canceled");
+  } else {
+    // nie wywołano preventDefault
+    alert("not canceled");
+  }
+}
+
+

 

+

 

+
+  
+

{{ languages( { "en": "en/DOM/dispatchEvent_example", "es": "es/DOM/dispatchEvent_example", "fr": "fr/DOM/dispatchEvent_exemple" } ) }}

-- cgit v1.2.3-54-g00ecf