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

3
votes
2answers
37 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
47 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
65 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 ...
4
votes
1answer
71 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
48 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. ...
7
votes
1answer
86 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
73 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
51 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
330 views

forEach and NodeList

This is loosely based on one of W3_School samples: ...
3
votes
2answers
72 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
63 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 ...
9
votes
3answers
181 views

Updating Grid on Webpage (new version)

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 entire ...
5
votes
2answers
113 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
49 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
59 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
305 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 ...
7
votes
2answers
132 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
47 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
115 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. ...
1
vote
1answer
126 views

WebGL ( Three.js ) simple application ( only js without html/css )

I have done the source code for my lesson, which I shall publish later in web at my website, let's look at it: ...
0
votes
3answers
135 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 ...
1
vote
1answer
28 views

CSS Styling: Should I specify the element type?

Which of the following is better code: div#style1{ } or #style1{ } Also, should the element type be specified for ...
2
votes
2answers
220 views

Javascript DOM Override Review

I'm building an mini-app that will display when changes to the DOM have been made by javascript. I have all of the functions that I can think of listed in the code. Is there a way to consolidate the ...
3
votes
1answer
379 views

Proper way of using IXMLDOMDocument

I am trying to use IXMLDOMDocument for XML reading/writing. I am not good COM, and I am not aware that I am doing things right or wrong. I am very unsure that there could be some problems with COM ...
3
votes
1answer
306 views

Custom event to match CSS :target pseudo-class

The following code makes jQuery trigger a new target event on elements when they become the target of the fragment identifier. For a very basic example, the ...
3
votes
1answer
287 views

First attempt at MVC JavaScript pattern

I would really appreciate a review of my interpretation of MVC here. It's as bare bones and clear as possible. I've based it on some in-depth reading but I don't know if I have understood everything ...
0
votes
1answer
77 views

Is this code likely to stand the test of time? (Add select box to DOM with JS)

The reason I asked about standing the test of time is that I previously used PHP echo to create a string and placed it into a div with .innerHTML, but modern browsers were not passing the value of the ...
4
votes
4answers
289 views

My first javascript sorting

I started learning JavaScript a week ago, and I made a sorting function on my own. It does work, but I need reviews and how to write a better one. ...
4
votes
3answers
424 views

Implementing an algorithm that walks the DOM without recursion

Here's a simple algorithm that walks the DOM given a node: ...
3
votes
1answer
85 views

Javascript Form Manipulator Code Review

I'd appreciate a review of at least some of this javascript, if anyone has time. It's really long, but I think it's useful. It's designed to let you create forms and do javascripty things by only ...
2
votes
1answer
641 views

Optimize Recursive Function to traverse nested DOM nodes

I wrote a recursive function that traverses nested DOM nodes of the following form: ...
2
votes
0answers
171 views

eDomForm - Dynamic Forms without Writing Any Javascript

I'd like some comments, and any suggestions for where to go next with this that you have. I've been working on developing a javascript library that allows for dynamic forms by simply adding some ...
3
votes
1answer
127 views

String processing in JavaScript

We have a lot of phone numbers that contain dashes and start with a zero which are from another country. I am trying to strip the dashes and the one leading zero and select the country code from a ...
5
votes
2answers
103 views

OOP approach to using DOMDocument

I've tried to write an "OOP" approach to printing a website using the DOMDocument class. I'm kind of stuck here because I feel like I am blundering in how I am passing and using the DOMDocument. I ...
1
vote
1answer
130 views

Better way to hide, change and show DIVs in Javascript

I made this Javascript to hide, show and change some DIVs but I believe it's not really good code. Can you help me to make it better? ...
1
vote
1answer
70 views

when we need to add some javascript code to html, where we have to put it?

when we need to add some javascript code to html, where we have to put it? What is the best practice: in line: ...
7
votes
1answer
247 views

Very fast query selector — did I miss something?

A few months ago, I wrote a query selector that seems to outperform the query selectors in the popular GP libraries by a pretty hefty margin. I'm wondering if I overlooked something; it seems odd that ...
8
votes
2answers
161 views

Simplify JavaScript

is there anyway I can simplify this piece of javascript? It seems inefficient. ...
0
votes
2answers
2k views

Render Large jQuery Mobile Listview

I am trying to write an efficient loop for rendering a JQuery Mobile listview. Is this the most efficient loop? I append elements 100 at a time to try and allow the user to see progress without ...
3
votes
4answers
9k views

Get the value of the name attribute of each element with class=“class”

I need a function to get the value of the name attribute of each element with class="class". I was wondering what is the best way to do this, performance-wise. Currently I'm using jQuery and doing it ...
0
votes
1answer
192 views

Animating multiple DIV-Elements with JS and the DOM results in a low Framerate

Reposted from Stack Overflow here. I've just started programming with JavaScript and I am currently working on this hobby web-site project of mine. The site is supposed to display pages filled with ...
2
votes
1answer
387 views

Stripping formatting from text - Am I using an efficient jQuery selector?

I'm making a comment box using a contenteditable div, but I want to remove formatting from text a user might copy/paste into it (also no CTRL+B or CTRL+I shortcuts allowed either). Only "approved" ...
1
vote
1answer
172 views

Javascript looping fader animation

Here's a small module I've written that implements an animation which fades through the child elements in a container div on a continual loop. I realise I could have done this way quicker using ...
0
votes
2answers
856 views

Creating input when checking/clicking radio button

Let's straight to the point, I'm new in jQuery and played a bit with what can I do with radio button. I want to create ONLY one input type when I click the "Notice" radio button, I already using many ...
3
votes
4answers
231 views

What is the shortest snippet that emulates `include` in JavaScript without third-party scripts?

JavaScript doesn't offer a module system. There are many third-party solutions, like require.js or jQuery's $.getScript. Most, ...
5
votes
4answers
506 views

Improve speed for looping through 1,000's of items in javascript?

This is a script I use to count how many items are selected in a form. Currently it loops through the entire form to count how many check boxes are selected, each time a checkbox is clicked. The form ...
3
votes
1answer
482 views

Simple DOM mutation abstraction

Background: I need to use mutation observers to watch for nodes being added/removed under a specific element. The code below is an attempt to implement something re-usable that uses ...
2
votes
2answers
46 views

Selector targets overly obtuse - recommendations?

This presumably simple task resulted in much more scripting logic than I thought would be necessary. Goal: when the user clicks a button inside one of the divs, it affects said div. Issues: I did ...
4
votes
3answers
2k views

JavaScript function to get DOM elements by any attribute

I needed to write a function today in JavaScript that would return all elements based on a given attribute. e.g retrieve all elements that have an id attribute in them. The function I wrote for ...