Skip to content
Advertisement

Tag: dom

appending to the DOM – vanilla javascript

I wanted to practice my vanilla javascript skills since I’ve been so library-heavy lately. My goal was to filter an array of JSON data (by events after 10/01/2015), and then append them as list items to the DOM, with the class being “events”, and give the ability to delete events. Why isn’t this working? https://jsfiddle.net/youngfreezy/7jLswj9b/ Answer when you do: listItem

Detect click outside React component

I’m looking for a way to detect if a click event happened outside of a component, as described in this article. jQuery closest() is used to see if the target from a click event has the dom element as one of its parents. If there is a match the click event belongs to one of the children and is thus

TextNode or textContent?

What’s the advantage of creating a TextNode and appending it to an HTML element over setting directly its textContent? Let’s say I have a span. And I want to change its text. What’s the advantage of using : over span.textContent = ‘hello’; Answer It ‘s not really matter of advantage but of proper usage depending on the need. The fundamental

document.querySelector multiple data-attributes in one element

I’m trying to find an element with document.querySelector which has multiple data-attributes: I thought about something like this: But it does not work. However, it works well, if I put the second data-attribute in a child-element like: So, is there an option to search for both attributes at once?I’ve tried several options but I don’t get it. Answer There should

Difference between document.hidden vs document.hasFocus()

Please explain the difference between document.hidden , the HTML5 Page Visibility API and document.hasFocus(). I am doing a project which pops HTML5 Desktop Notification when the tab is not focused. I am kind of confused which one to use. Answer The hidden attribute is defined like this: On getting, the hidden attribute MUST return true if the Document contained by

Advertisement