dom

page elements loaded before script

Hi, I was wondering if I could do the following: load a html page and set the backgroung color of the body element dynamically with javascript, in this case with a jquery script. If the page elements are loaded before the js executes, then the body color will be white for a second, and then it changes the color. If the js would be load...

Subclassing from (extending) an HTML element?

I'd love it if I could make my own class that extended an HTML element class, e.g. HTMLDivElement or HTMLImageElement. Assuming the standard inheritance pattern: // class A: function ClassA(foo) { this.foo = foo; } ClassA.prototype.toString = function() { return "My foo is " + this.foo; }; // class B: function ClassB(foo, b...

How would I traverse elements between two known elements in the dom using jquery?

I want to allow the user to click a start point and then click an ending point and be able to manipulate various form elements between the two points that were selected. The page is a table with numerous rows and each row contains the relevant information to manipulate/save an answer to the question in that row. Each row has a hidden in...

How to unset id attribute with jQuery?

$().attr('id','') still leaves id = "" snippet, how to completely remove it? ...

generically detecting html position changes using jquery?

I'm using the excellent BeautyTips plugin as a means of indicating validation failures to end users and I'm running into positioning problems whenever page content is dynamically added, removed, or animated. Here's a concrete example. I have a DIV at the top of each page that’s used for confirmation/error messages. It's displayed in $...

Fastest way to append HTML content to a div using JavaScript

I have an HTML page that uses AJAX to retrieve messages from a server. I'm appending these messages to a as they are retrieved by setting its innerHTML property. This works fine while the amount of text is small, but as it grows it causes Firefox to use all available CPU and the messages slow down to a crawl. I can't use a textbox, bec...

jQuery html() in Firefox (uses .innerHTML) ignores DOM changes

I'm really suprised I haven't run into this problem before, but it seems that calling jQueries .html() function on an element ignores changes in the DOM, i.e it returns the HTML in the original source. IE doesn't do this. jQueries .html() just uses the innerHTML property internally. Is this meant to happen? I'm on Firefox 3.5.2. I have...

Setting priorities on HTML Events

We have a Web system that uses a combination of OnBlur and OnMouseDown events. Unfortunately, for a strange reason the OnMouseDown event handler is being triggered before calling the OnBlur event handler. This is not what we want. Instead, we want to always call the OnBlur event handler prior to calling the onMouseDown event handler. I...

plain javascript code to highlight an html element

to debug some javascript code, I am looking for javascript code (preferably just js, without libraries and dependencies) that can highlight a div or span (probably by putting over it a div or span of the same size and shape with a bright color and some transparency). I pretty sure it can be done, but I don't know how to start. CLARIFIC...

How do I add textboxes dynamically in Javascript?

By default I have 5 textboxes. When a user clicks on a button, one textbox should be added. How could I do this? ...

Java: Create DOM Element from Element, not Document

As you know, the proper way to create a Dom Element in Java is to do something like this. import org.w3c.dom.Document; import org.w3c.dom.Element; Document d; Element e; e = d.createElement("tag"); You need to use d to generate the element because it needs a document context. (I'm not 100% sure why, but maybe misunderstanding this i...

How to destroy a DOM element with jQuery?

Suppose the jQuery object is $target. ...

Can a DOM element have an ID that contains a space?

And if so, how do you select on with jQuery? I.e., $("#a b") looks for all <b> nodes within the node with id=a. ...

Inconsistency in jQuery's attribute manipulation

$('<option selected="selected">something</option>') .removeAttr('selected') .wrap('<p></p>').parent().html(); results in <option>something</option> which is expected. But if I put back the 'selected' attribute after removing it (or to an <option> tag without 'selected' attribute), I get the same output. $('<option selected="selecte...

Dojo - dojo.byId() over an ajax response

Hi all I'm using Dojo support for Ajax function handleSubmit(evt, targetUrl, submitForm, updateDiv) { dojo.stopEvent(evt); dojo.xhrPost( { url: targetUrl, handleAs: "text", load: function(response){ updateDiv.innerHTML = response; wireEvents(); return response; ...

Adding an event listener to an iframe

Is it possible to add an event listener to an iframe? I've tried this code, but it doesn't seem to work: document.getElementsByTagName('iframe')[0].contentWindow.window.document.body.addEventListener('afterLayout', function(){ console.log('works'); }); I've also just tried using getting the element by id and adding my li...

Highlight all data in a HTML Table

Is there a way to do a selection highlight over all elements in a HTML Table? I want to be able to have data displayed in a tabular form, and the user to be able to click a button to select the relevant data to copy and paste into the spread-sheet of their choosing. ...

Proper DOCTYPE... custom attributes and non-standard markup.

Ok, don't get me wrong, I absolutely love the idea of web standards... wrote and validated a number of pages with strict XHTML 1.0 - however, the web is evolving... and the more I use XML, realize the capacity of the DOM, and realize most browsers don't care one way or the other, the more I realize I realize I just want to break conventi...

Forcing a DOM refresh in Internet explorer after javascript dom manipulation

Here is the situation. I have some javascript that looks like this: function onSubmit() { doSomeStuff(); someSpan.style.display="block"; otherSpan.style.display="none"; return doLongRunningOperation; } When I make this a form submit action, and run it from a non IE browser, it quickly swaps the two spans visibility and...

Retrieving XML results of a POST command

As part of my GWT application I have a POST method that accepts a file (so I need to use form submission) and returns an updated list of elements as xml. I use the GWT formPanel to do this. The formpanel redirects the results of the post into a separate iframe. Using the dom inspector I can see that the results are actually there. Unfort...