addEventListener can take a third argument that can control the event propagation. So, I listened for a click on my modal screen div and forced refocus on a popup button. Programmatically navigate using React router. Call multiple JavaScript functions in onclick event. Since the content is in the div if you do not stop the event propagation both will receive the click. While using W3Schools, you agree to have read and accepted our, Sets or returns the accesskey attribute of an element, Returns the currently focused element in the document, Attaches an event handler to the document, Displays an alert box with a message and an OK button, Returns whether the "ALT" key was pressed when the mouse event was triggered, Returns a collection of all elements in the document that have a name attribute, Adds a new child node, to an element, as the last child node, Returns a collection of all elements in the document, Returns the version information of the browser, Writes an error message to the console if the assertion is false, Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians, Returns the arctangent of the quotient of its arguments, Returns a NamedNodeMap of an element's attributes, Returns the height of the screen (excluding the Windows Taskbar), Returns the width of the screen (excluding the Windows Taskbar), Loads the previous URL in the history list, Returns the absolute base URI of a document, Sets or returns the document's body (the element), Returns whether or not a specific event is a bubbling event, Returns which mouse button was pressed when the mouse event was triggered, Returns which mouse buttons were pressed when the mouse event was triggered, Returns whether or not an event can have its default action prevented, Returns x, rounded upwards to the nearest integer, Returns a list of all the touch objects whose state changed between the Article Contributed By : dikshapatro. The first argument specifies the array position for insertion or deletion whereas the optional second argument Find centralized, trusted content and collaborate around the technologies you use most. Where should you put the js files script tag in an HTML file? Code Answers the next repaint, Resizes the window by the specified pixels, Resizes the window to the specified width and height, Stops the execution of a function and returns a value from that function, Reverses the order of the elements in an array, Returns the previous node at the same node tree level, Returns the previous element at the same node tree level, Displays a dialog box that prompts the visitor for input, Allows you to add properties and methods to an object, Returns the element related to the element that triggered the mouse event, Removes an event handler from the document (that has been attached with the, Returns the horizontal coordinate of the window relative to the screen, Returns the vertical coordinate of the window relative to the screen, Returns the horizontal coordinate of the window/mouse pointer relative to the screen, Returns the vertical coordinate of the window/mouse pointer relative to the screen, Returns a collection of