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

1
vote
1answer
31 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
70 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
222 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
27 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 ...
2
votes
0answers
46 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
53 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
29 views

Extracting a list of hyperlinks [closed]

I need to produce a list objCollector with some results: ...
1
vote
1answer
114 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
54 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 ...
3
votes
0answers
74 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
71 views

Improving code for my 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
95 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 ...
1
vote
1answer
51 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
47 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
94 views

Page Spider in PHP

I have a working spider, however, it runs fairly slowly thanks to Australia's horrible internet. Can anyone give me some tips on speeding this up? ...
2
votes
1answer
55 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
186 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
91 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
63 views

Caching DOM-queries

I've been optimizing my code and I always tend to cache common selectors like this (jQ): ...
2
votes
4answers
141 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
58 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
125 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
90 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
137 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
72 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
39 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
231 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
87 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
3k 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
52 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
39 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
107 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 ...
4
votes
1answer
157 views

Get all the attributes of a DOM Node

I needed this small function for one of my project. Fetch Attributes ...
4
votes
2answers
209 views

Get <TH> texts into a tab separated string

table_with_headers = $(this.dom.table).find("thead tr th").map(-> $(this).text() ).get().join("\t") Can one write it nicer? I especially dont like the inner ...
6
votes
1answer
83 views

Generating DOM from a complex strings via arrays

This is a revised and expanded version of Transforming complex strings into simple arrays My function grabPerson turns strings of user information from multiple ...
3
votes
2answers
126 views

Performance of a method to mask all but one rectangular element on the page

The point of this code is to mask a page where the user is editing the page's 'body' content. This is in a CMS. The rest of the page is the website template (i.e. header, index bar etc...). I've ...
3
votes
1answer
431 views

Validate XML using XSD, a Catalog Resolver, and JAXP DOM for XSLT

Background As this related question describes, there does not appear to be a canonical way to validate XML files against an XSD then subsequently transform them using an XSL template with file paths ...
6
votes
1answer
137 views

Tiny DOM builder

My goal was to create a tiny DOM builder library that made creating element trees less gross. This is the syntax I decided on: ...
1
vote
1answer
64 views

Assignment Chaining

In the following code, I've just parsed an JSON object called responseObject from an AJAX call, one of whose members is an array of objects called ...
6
votes
1answer
9k views

Manipulate HTML document loaded into WebBrowser control

I have developed my custom solution for this. It happened that the first solution is using XPath queries and the second, a conceptually similar to the first one, is using CSS queries processed by ...
3
votes
1answer
94 views

Recognizing elements and doing event handling for repeating templates

This fiddle has an ADD button when you click it a Chat window is added. When there are more than 1 windows the message from one window is reflected across all the windows. Say you have templates (in ...
2
votes
2answers
263 views

List of search results using Selenium

I have written the following code for looping through WebElements in Selenium. Can someone please provide me with feedback on how to improve my code? ...
3
votes
2answers
170 views

DOM building using DocumentFragment

I want to build the markup below by iterating on an array of objects. The structure of the object is also listed below. I need some tips on how to make it clean. Markup I want to build: ...
2
votes
1answer
57 views

b10k minigame problems

I tried to recreate a mini game (not sure about its name, I call it b10k) with 2048 looks, therefore it looked better if I use html elements, and I really am not good at working with them, but I ...
1
vote
0answers
64 views

Optimizing jQuery table building by replacing appends with string concat

I've wrote some code to create a grid of data, however depending on the size of the grid being drawn, IE8 shows a warning message about a long running script. I've read that multiple appends are a ...
1
vote
1answer
143 views

Alternative to null check after DOM traversal?

I have this code working, but I'm not sure if it's the best way to write it. I was watching a JS talk on Maintainable JavaScript, and saw that I probably shouldn't be comparing my element to null, ...
3
votes
2answers
46 views

HTML/Attrs Tester Environment

I have a few objectives (which are working fine, but I want tips in case I can improve it). Let me try to make this as clear as possible, as this is a much larger project: There are three move ...
4
votes
2answers
83 views

Accessible tabbed UI

I've started working on a script that turns sections with headings into a tabbed interface. The repo is at https://github.com/derekjohnson/tabs and a demo at http://derekjohnson.github.io/tabs/ It ...
4
votes
3answers
79 views

New Game - Am I going down the right path for DOM manipulation?

I find myself using a lot of .find functions within what I'm developing. The reason being that I need to run this same function on a TON of different characters ...
3
votes
3answers
208 views

Correct use of appendChild

I want to be able to append a value to the bottom of a list and I set a node to create and element of <li> and then set the text document node to my value. ...