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
28 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: <script type="text/javascript">document.write(new ...
2
votes
0answers
61 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 ...
7
votes
2answers
131 views

Simplify JavaScript

is there anyway I can simplify this piece of javascript? It seems inefficient. $(function () { var $carousel = $('#carousel'); var $switch = $('#switch'); var $header = $('#header'); ...
0
votes
2answers
79 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
102 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
43 views

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

Repost from Stackoverflow (here): I 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
68 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
104 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
82 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 ...
5
votes
4answers
256 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 ...
2
votes
0answers
188 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 MutationObservers ...
2
votes
2answers
42 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
2answers
227 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 ...
3
votes
2answers
154 views

How can I reduce/improve this code?

I'm updating and old project from jQuery 1.4 to jQuery 1.7. Having the following code: var cartItemDel = '<td class="del"><img src="components/themes/default/img/icons/cross-small.png" ...
1
vote
0answers
72 views

Could this be done better? Looping through DOM to modify elements

I'm using this PHP to modify A elements in a DOM fragment (a vBulletin $post['message'] if that matters) so that links to external sites always open new tabs. This is actually the default in vBulletin ...
1
vote
2answers
93 views

Can I adjust this code which displays a table to run faster?

this.displayData = function () { var i; var $thead = $(thead); var $tbody = $(tbody); var numberOfFields = columnDataFields.length; var numberOfRows = data.length; // ...