The process of changing the Document Object Model (DOM). It includes adding, removing or changing DOM elements.
Questions tagged [dom-manipulation]
825 questions
7
votes
3 answers
Add option to a select and select it
I have this code
var opt = $("select option:first");
opt.remove();
$("button").on("click", function() {
$("select").prepend(opt).val(1);
});
That works fine in some browser. But, of course, IE isn't one of them. In IE the combo ends with the…

Diego
- 16,436
- 26
- 84
- 136
7
votes
2 answers
Most efficient way to add remove classes with JavaScript
I am curious if anyone knows which of these is more efficient, I am only concerned with Firefox as a browser and do not need to know that this code doesn't work in IE, etc...
Basically I am showing and hiding DOM elements based on an input field's…

macguru2000
- 2,042
- 2
- 18
- 27
7
votes
3 answers
jQuery - move element and return to its exact previous location?
I'm trying to use jQuery to move an element from one location to another in the DOM. There are elements identical to the originating container alongside it, so how do I store its exact previous location so it will return back to it? Here's an…

Charles
- 167
- 1
- 5
- 15
6
votes
2 answers
jQuery add closing tag and then reopen when using .before()
I have this HTML:
- a
- b
- c
- d
- f

Scott
- 3,967
- 9
- 38
- 56
6
votes
2 answers
Performance for appending large element/datasets to the dom
I am appending large amounts of table row elements at a time and experiencing some major bottlenecks. At the moment I am using jQuery, but i'm open to a javascript based solution if it gets the job done.
I have the need to append anywhere from…

Derek Adair
- 21,846
- 31
- 97
- 134
6
votes
1 answer
Angular Stripe - Converting Stripe Payment Form to Stripe Elements
I used to have Angular Stripe Checkout form and I am trying to update my form to the new Stripe Card Elements which was introduced recently.
After removing the Form Input fields and replacing them with the Stripe Card element, my form looks like…

Neel
- 9,352
- 23
- 87
- 128
6
votes
2 answers
Reach Jekyll Variables With JavaScript and Pass it Throught DOM Manipulation
Highly possible that I have error logic but I'm just learning both JavaScript and Jekyll.
My goal is to manipulate an HTML element through JavaScript and place some Jekyll variable inside the inner HTML of that element. Everything is loading from a…

hzoltan
- 95
- 1
- 8
6
votes
5 answers
Why is it considered a bad idea to manipulate DOM in controllers?
Many People have told me that it is a very bad thing to manipulate DOM in controllers, but what exactly is the reason. How does it affect the application that you are making?
What are the Best Practices to do that and how is it done?

Vikram Singh Jadon
- 1,007
- 1
- 10
- 23
6
votes
2 answers
jquery .data lost after remove() and append()
Sorry, this seems like a stupid question... but is this actually expected behaviour?
I store data on some element:
$('#source-list li.active').data('relation-text', textEditor.value());
Later the element is moved from one list to…

Wolfgang
- 2,188
- 1
- 25
- 24
6
votes
3 answers
JavaScript to sort DOM elements by some comparator, without jQuery
Imagine some DOM elements:
- Baz
- Foo
- Bar

Drew Noakes
- 300,895
- 165
- 679
- 742
6
votes
3 answers
Jquery resize() causing screen flickering and div offset
The Background:
I am trying to create a system that allows to scroll through a kind of map using mouse scroll up and mouse scroll down like so:
-------
| |
| 1 |
| |
-------
------- ------- ------- -------
| | | …

lorenzoid
- 1,812
- 10
- 33
- 51
6
votes
8 answers
document ready after dom manipulation
I'm doing an application with Phonegap and I'm using a self-built slide transition to change the pages.
It works like this:
Every page is a div with 100% height and width, so if I change the Page, I set the next div right to the currently active…

Michael Kunst
- 2,978
- 25
- 40
5
votes
2 answers
How to load plain text in to div from another page
I'm trying to load content from another page div into another page div.
What i've got:
JQUERY:
$('#news_date-1').load('test.php .news_date-1');
TEST.PHP
20-11-2009
Destination.html
The…
ronni
- 185
- 2
- 3
- 11
5
votes
3 answers
Randomize order of links on page using jQuery
I have a list of links sitting inside a tag right now. I would like for the page to 'reorganize' the order of each link on page reload (page view) and display the results.
For example: