The Document Object Model (DOM) is an application programming interface (API) for valid HTML and well-formed XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated.

learn more… | top users | synonyms

0
votes
0answers
17 views

PHP FormBuilder class

I've taken some suggestions from this question and tried to build my own FormBuilder class. It's supposed to work like this: Creates an object of type form ...
1
vote
0answers
27 views

Large table updates using AJAX in Internet Explorer 11 (Cont'd)

Previous topic: Large table updates using AJAX in Internet Explorer 11 For the functions included here, I have taken the advice of the previous answer and incorporated it in the restructure, but am ...
2
votes
1answer
61 views

Generating calendar months for a datepicker

I got a problem I'm finding pretty hard to solve. I'm trying to generate calendar months for a datepicker but at only 12 months I see a perf of around ~4-7ms. This doesn't sound like a problem but it ...
1
vote
0answers
17 views

Angular resize directive

I have created this directive in Angular. The idea is to calculate width of height and height of specific element via style function attached to ng-style on the same element. The directive uses ...
6
votes
2answers
79 views

Hours:Minutes Addition

I wrote this simple page to help at work, and as an exercise to get more familiar with JavaScript. I'm especially interested in help with style and structure - is this "standard"? I know the input ...
2
votes
2answers
30 views

Extracting distinct HTML list items into a JavaScript array

This code is made to generate a list of unique elements of the array made of the other two arrays. The fact that we need two lists to convert in two different array is part of the task. This code ...
1
vote
1answer
23 views

Checking if a tag is on the screen

This function receives an HTMLElement as an argument and returns true if the tag is on the screen and ...
3
votes
1answer
87 views

Animating sprite without libraries

I'm building a small game in pure JS for my own learning purposes, using sprites to model players. Before I go further, I want to try to get the animation down. The below code should produce a blank ...
1
vote
1answer
28 views

Scrolling with an easing function

I wanted to write a function that when invoked, will scroll the page downwards in a smooth fashion. Comments and criticism welcome. I don't like, for example that determining whether it is done is ...
1
vote
3answers
83 views
3
votes
2answers
55 views

Dynamically creating elements with an object constructor

Just experimenting with various Javascript techniques and was wondering if the code below is valid and if there are any disadvantages to using this technique to create html tags from JS object ...
3
votes
2answers
58 views

Show and hide posts using setTimeout

I have made an effect that has the h1 move and then reveals p using .addClass, ...
7
votes
1answer
340 views

Converting partial XML (Node List) to a String

I have a need to extract a part of XML tree (everything under root) and convert it to a string. (The result string will be later pasted inside ...
11
votes
2answers
139 views

Early Access: Dynamically expanding input element table

This code is in a really early state in the lifecycle. I'm still in the process of implementing some core features, but nevertheless the code up to here works and accomplishes its task. I have no ...
12
votes
3answers
780 views

Lights on: playing with buttons in Javascript

First play with the game a little bit, and it is quite fun (a little hard but very satisfying when you win, be sure to put it full page): ...
4
votes
1answer
57 views

Limiting the number of text fields created

I need to make sure that the max of text fields created is limited to 10 at most. It's a script that I've ripped off elsewhere, and have modified it via help from StackOverflow on a couple of other ...
3
votes
1answer
2k views

HTML and JS to dynamically load, refresh, and execute JavaScript from external file

The following code is designed to load and refresh JavaScript code from an external file sandbox.js and allow it to be refreshed dynamically and executed without ...
2
votes
1answer
58 views

jsonToDOM Function

For the MDN documentation website we have written this jsonToDOM function and I was wondering how you all would improve it. It takes a json structure and creates ...
4
votes
1answer
81 views

Generate form and append to the body

I'm writing a plugin and want it to have no dependencies. I create a form and append it to the page, but the code is really long. Does anyone have any suggestions to clean it up, perhaps shortening ...
1
vote
1answer
72 views

Organize dynamic HTML generation function for audio player

I have some code that's part of my music-js library, and most of it is very organized, using object-oriented design for my AudioAnalyser and ...
2
votes
1answer
194 views

Use DOM and XPath to make some changes in HTML document

I intend to make some changes in an HTML document, like remove, replace, append some nodes. I have several arrays with same structure like the following example ...
4
votes
1answer
242 views

Sending Ajax requests and updating DOM

I wrote some ugly JavaScript that is responsible for sending Ajax requests and update the DOM. I'm using it to show user progress of background jobs. ...
1
vote
0answers
40 views

Appending a group name to each committee member

I wrote this script to get text, if it equals, append the name of the group to a person's information. I know using .each() is gpu intensive and this feels like a ...
3
votes
1answer
749 views

Truncating text with jQuery but keep the HTML formatting

I repeat here this answer on Stack Overflow. I first posted an answer with not finalized code, as a simple description of the solution I could think, without any test. But later I remained ...
-1
votes
2answers
56 views

Filling in comment replies when link is clicked

To append data I am using parent() method five times in the code and I think it seems like an ugly way to do this. ...
1
vote
1answer
32 views

Extracting a list of hyperlinks [closed]

I need to produce a list objCollector with some results: ...
1
vote
1answer
2k views

Use Promise to wait until DOM element exists

I need to create a JavaScript Promise that will not resolve until a specific HTML element is loaded on the page. I don't have any way of knowing when this element will be loaded, other than to simply ...
2
votes
1answer
321 views

Practicing recursion with getElementsByClassName

I'm trying to get a good grasp on recursion by implementing document.getElementsByClassName. I've made something that works but I'd like to know if there is some ...
5
votes
1answer
228 views

jQuery selector function in JavaScript

I've reproduced the jQuery selector function in JavaScript. Here are the two rules that come with this function: You may not use any JavaScript libraries. ...
1
vote
1answer
84 views

Adapting new design pattern with post handler

I'm currently using this pattern in my JavaScript code. Somewhere in my code I use Dnianas.Post.init. init fires and it will ...
1
vote
1answer
573 views

Get InnerHTML, OuterHTML, and plain text of an element by ID or class

I do a fair amount of scraping but I am by no way a good PHP programmer. I always struggle to get the innerhtml of elements using PHP, domdocument and XPath. I have cobbled together a couple of ...
2
votes
1answer
97 views

DOM Traverser in JavaScript

I'm writing a function in JavaScript which, when given an element, can look for the previous or next node, assuming a depth-first order traversal. If the next element is out of bounds, it should ...
2
votes
2answers
63 views

Toggling classes on many elements when a button is tapped

I have this very easy functionality to find, toggle and remove classes from my html elements. The thing is that I find my self repeating the same code with just different name classes. I basically ...
2
votes
1answer
60 views

Slider with JavaScript

I built this simple slider with JS, but I am not so experienced with programming and I wonder what can be improved in this code, how to dry it, or how to apply some OOP paradigms to it, what is not ...
6
votes
1answer
2k views

Simple todo list

Can someone tell me how good/bad this code is for a super simple todo list made from vanilla JavaScript? Anything to work on or consider on my next projects? ...
3
votes
2answers
105 views

Piccoche - a coordination game

Click the divs to remove them. Remove all div's in the shortest time and minimal clicks (to do). Code needs streamlining. ...
1
vote
1answer
76 views

Caching DOM-queries

I've been optimizing my code and I always tend to cache common selectors like this (jQ): ...
2
votes
4answers
268 views

Returns an array of all inputs with specified name

I've made a nice little function to return a NodeList array containing all the inputs that have a specified name attribute: ...
2
votes
0answers
123 views

handle drag and drop operations

I've come up with the following code to handle drag and drop operation. It's composed of a constructor function that returns an objects with methods to attach to event handlers. Notes about this ...
2
votes
1answer
281 views

Efficient Traversal and Manipulation of the DOM with Native JavaScript Using For/In Loop

With native JavaScript, I intend to traverse a collection of elements in the DOM that contain a link and an image (and possibly other elements). The image may or may not be inside the link—in ...
2
votes
1answer
152 views

AJAX call with repetitive success/failure handlers

There's some repetition in here. I tried making it into a function but then the response wasn't filling up the ...
5
votes
2answers
200 views

Periodic Table generator

I've been playing around with Jekyll and CoffeeScript the last few days and made a Periodic Table to learn those two. Now, to create the Periodic Table, I take an array of ...
0
votes
1answer
74 views

Recursive functions

I am using the following code which recursively executes function findWpisInZone(), code works fine, I just wondering if there is any better way to do it in JS, ...
1
vote
1answer
43 views

Adding classes with JavaScript

I am working again and got this to work. Is this the best way to write this code? ...
1
vote
0answers
395 views

Cleaning up a custom checkbox implemented using the shadow DOM

I'm porting Google's "paper elements" checkbox out of Polymer. This implementation doesn't use two-way data-binding. Instead, it relies on a few event handlers. Everything works, but it feels pretty ...
1
vote
1answer
119 views

PHP DOM XML Creation

I am currently working on Shopify webhooks which posts XML to the Colorado timber line API. But due to the order protocol of the Colorado timber line API, it is required to modify the XML posted by ...
1
vote
1answer
8k views

Displaying data from JSON in a table

What do you think of my code? I know it is a little rough around the edges but as of two days ago I had no idea how to use jQuery or JavaScript. ...
2
votes
1answer
53 views

Using TAGS with <script> on your websites

This function creates a series of links at a desired destination by the usage of a premade tag system. Usage: createMyTAGS_DATA passes in a single line of all ...
2
votes
1answer
47 views

JavaScript library for cookie information

I've always struggled to write JavaScript code that I thought of as great and "correct" code. And I've struggled to find good information on how to do it. Recently I was given a task at work to write ...
5
votes
2answers
172 views

Equal heights in pure JS

I'm pushing myself to learn pure JavaScript, so this morning I wrote an equal heights script in jQuery and then converted it to JavaScript. It works, but I'm using two ...