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

2
votes
3answers
75 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
20 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
45 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
55 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
113 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
66 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
36 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
44 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
451 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
50 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
32 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
75 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
94 views

Get all the attributes of a DOM Node

I needed this small function for one of my project. Fetch Attributes ...
4
votes
2answers
161 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
79 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
88 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
241 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
98 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
56 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 ...
5
votes
1answer
5k 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
70 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
148 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
101 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
53 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
58 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
123 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
44 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
78 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
77 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
193 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. ...
4
votes
1answer
90 views

Triggers placing and sizing elements for video controls

I have some triggers placing and sizing elements for video controls. It works well enough but mostly through trial and error and I am not sure if there is a better pattern: The full source can be ...
2
votes
1answer
1k views

How to do a small calculation on a drop down when clicked?

I have a form that requires a calculation when clicked on a multiple drop down selector, and still displays the clicks of the courses in real time and lastly calculates the sum total of the courses. ...
6
votes
1answer
337 views

Interactive slider

Task: Create an interactive slider that allows the user to view a given image gallery. Slider controls: See previous slide See next slide Quick navigation through the images / Paging - ...
5
votes
1answer
132 views

Optimise JavaScript DOM update

I'm building a virtualised grid in JS/HTML and finding browser performance with large grids fairly slow, particularly in IE10/11. The following jsfiddle roughly represents my worst case scenario, ...
4
votes
1answer
180 views

Fix base64 data URI scripts function

So I noticed Chrome has quirky behaviour when it encounters script tags whose src is a base64 value. I decided to write a quick ...
4
votes
2answers
726 views

forEach and NodeList

This is loosely based on one of W3_School samples: ...
3
votes
2answers
86 views

Horizontal menu for 3 items

My task was to create a menu that displays three items (A,B,C), and has two nav buttons <- and ...
0
votes
3answers
189 views

Image Carousel in JavaScript

I created a very basic "image projector" that shows the current one and shows the next on clicking into the image. And yeah, it works, but I don't think that's a very elegant way to do it. Any advice ...
2
votes
2answers
141 views

Showing/hiding a box containing a Facebook profile

I see that there are quite some words that are appearing double or more times in my code. I'm thinking there might be a more efficient way of writing this code, only I don't have the knowledge to do ...
11
votes
3answers
213 views

Updating Grid on Webpage (new version)

Previous version: Updating Grid on Webpage Task: Draw a grid with a given number of rows and columns. Each cell can be any color. The same grid should also be updated at a predetermined time ...
5
votes
2answers
140 views

Updating Grid on Webpage

Task: Draw a grid with a given number of rows and columns. Each cell can be any color. The same grid should also be updated at a predetermined time interval. The grid should cover the ...
1
vote
1answer
150 views

JavaScript Sticky Footer

I'm using this JS to sticky website footers at the bottom and I would like to know if is there anything to be optimised? ...
3
votes
1answer
192 views

Best practice to create XML messages with DOMDocument class in PHP

I want to create XML messages for webservice communication. These messages should be created from a pool of reusable elements. Therefore I have created different classes. A "factory" class, that only ...
6
votes
1answer
680 views

MutationObserver (shim): Finding differences between 2 DOM trees

I've been working on a MutationObserver es5 shim and would appreciate some feedback on my technique for identifying changes between a ...
8
votes
2answers
176 views

JavaScript Game Engine Design

I recently gutted and redid my game code to be object oriented (before it was just functions and a mass of global variables. Before I go an make more functionality happen, I would like to take one ...
1
vote
0answers
76 views

DOMDocument grouping nodes, with clone, nodeClone, importNode, fragment… What the better way?

A "DOMNodeList grouper" (groupList() function below) is a function that envelopes a set of nodes into a tag. Example: INPUT ...
2
votes
2answers
272 views

DOM parser implemented from scratch

I have implemented a DOM parser. I would like any comments for optimizing, improving, and making the code coherent to best coding practices. ...
3
votes
1answer
188 views

WebGL (Three.js) simple application

I have done the source code for my lesson, which I shall publish later on my website: ...
0
votes
3answers
248 views

Creating chunks of HTML with jQuery

I am working on an online ordering form and am looking for some advice about my jQuery. I am re-developing the code base for this ordering form and improving what was created by a web design group ...