dom

How can I attach event handlers to dynamically-generated DOM elements using jQuery?

I have a <ul> tag that I want to append some <li> tags inside. Example: $('body').append("<ul id='myUL'>").find("ul"); $('#myUL').append('<li id='a'>a</li>'); $('#myUL').append('<li id='b'>b</li>'); I want to give every <li> a different click event. How can I accomplish that? ...

How to insert a comment before the root <svg> element?

How to add a comment node before the root <svg> element but after the xml prolog? Or will it be less resource expensive to insert the comment with a regexp on the serialized DOM? ...

Node.normalize() crashes in IE6

I am doing some manipulation of TextNodes in javascript, and I (unfortunately) need to support IE6. Node.normalize() is crashing, and I need to work around this. My first inclination is to just re-implement it using other DOM methods. How would I implement this? ...

Zend Framework dom problem

Hi i use zend_dom. I want to get website shortcut icon(favicon) and stylesheet path with zend_dom query $dom = new Zend_Dom_Query($html); $stylesheet = $dom->query('link[rel="stylesheet"]'); $shortcut = $dom->query('link[rel="shortcut icon"]'); Stylesheet query is work but shortcut icon query not work. How i do? Thanks. ...

Element ID in HTML Document ~ Naming Question

Are there any issues (either technically, or otherwise) with putting a space character in an element ID? For example, something like this: <li id='something with spaces'>Test123</li> I understand that this is NOT desirable (I have never used spaces before), but I have hit a scneario where I need to do this if possible. What are the p...

User Definable Attributes on HTML Elements?

What I need to do is be able to store some piece of data about an element. For example, lets say I have a list item <li>, and I want to store some data about it in the element, like "This is element 1 from XYZ". The only way I know how to do this (which I don't want to do if I can avoid) is this: <li id='item1'> Item 1 <!--This is...

temporarily removing and later reinserting a DOM element?

Hello, Is there some jquery magic that will let me do the following: [0- define some element in HTML (eg, a unchecked checkbox)] 1- update its DOM element by setting one of its attributes using .attr() (eg, by setting its "checked" attribute using .attr('checked', true) ) 2- temporarily remove that element from the DOM 3- reinsert t...

Why do registered events disappear when an element is removed from DOM?

This jQuery 1.3.2 code adds an element to the page, registers a "click" event, then removes and reattaches the element: var button = $('<button>Click me!</button>') .click(function(){ alert("Hello") }) .appendTo('body'); $('body').html(''); button.appendTo('body'); The button appears on the page as expected, but clicking on it ...

jQuery validate, can't get it to work.

OK, beating my head against the Javascript/jQuery wall over here, here is the code, which I simply can't get to work properly, any help is highly appreciated! Especially this bugs me, changing row 60 from c.gbForm.validator = c.dom.gbForm.validate(c.gbForm.validator); to c.gbForm.validator = $("#gbForm").validate(c.gbForm.validator); a...

How to attach JQuery to a non-jQuery-enabled page?

I wish to browse the DOM of an (arbitrary) web page to extract data and think jQuery would simplify the navigation problem. So after the browser, say IE, finishes loading a page (that does not already use jQuery), how can I: attach jQuery to the page's Document object? invoke a jQuery function via DOM? I appreciate your reply...

AJAX boardgame runs fine in Windows, but not in Linux

I have been playing a web boardgame called Empires at GamesByEmail.com recently. It runs fine under Windows, but is unusably slow on Linux. I asked the developer why. He uses Linux, but he does not know. He suspects there are too many DOM elements, but he does not know what to do about fixing the problem. It's slow both in Firefox and ...

dom:loaded not firing until the last <img> request is initiated. (prototype js)

Hi all, I'm working on a page with 60+ images and the dom:loaded event isn't firing until the last image request is initiated (not fully loaded, which is expected). On a slower connection (using some throttler to simulate this) it is very noticable. The dom:loaded event fires something that will kick in javascript interaction on the pag...

JavaScript getElementsByCustomTag('value')?

Hi, I know getElementsByName('something') that returns the elements with name="something", but I want to return a list of elements where custom="something", how would I do that? ...

Will I be able to get a list of registered event handlers on a DOM node inside a firefox extension?

I don't know a thing about implementing extensions in Firefox, but having not seen an extension that does anything like this in the Mozilla's addons page, I don't believe it is possible, but thought I will ask about it anway. ...

Run functions on elements with a certain class as soon as the DOM is loaded, not using an event handler

I have a simple function which I want to run on all elements with a certain class. I want this function to be run as soon as the DOM is loaded; not upon an event handler. Below is the code that will run on an event handler like hover. How do I make it run as soon as the DOM is loaded? $(document).ready(function(){ var displayname ...

dynimically created DOM can't hold up in cache

Hi I am building div content with AJAX call, but when I make call to any page from loaded page, if there is any exception the content loaded from AJAX call is not there in previous page. Is there any way to stop happening that? ...

can entire web document be cached/archived (including the precise state of the DOM) and later reloaded?

imagine that we have loaded a complex website with lots of Javascript which loaded all sort of info via AJAX and by making computations based on user input. So, now suppose we want to archive it in such a way that we can reliably load it later on from file (maybe even without an internet connection) and study its behavior / debug it / et...

PHP: Create new node inside parent

I have a root XML node called and I am trying to add a new child called to this but I am getting errors. Inside there is also children. Here is my code: $xml = new DomDocument(); $xml->load(X_ASSETS); $xml->formatOutput = true; $new_id = $this->getNewAssetId(); // Root $xpath = new DOMXPath($xml); $asset...

How can I use jQuery's replaceWith() function to make a href link trigger a function?

This is what I've tried: html: <div id="container"> <p>a paragraph</p> </div> <button>replace with link</button> script: $(document).ready(function() { $("a.foo").click(function() { alert('hello world'); }); function foo() { alert('hello world'); } $("button").click(function () { ...

Can a DOM Range object end before it starts?

The DOM specification on Range objects doesn't address whether a range can have an end container/offset that comes before its start container/offset. The Mozilla docs on Range.setStart() indicate that this isn't allowed. Is this a Mozilla quirk, or common behaviour? ...