dom

Binding events to not yet created DOM elements (jquery)

How do I bind events to html elements that don't exist at the time of the script loading? One part of my script adds these to the DOM: <a class="btn-remove-item" href="">link</a> The problem is I can't just do: $(document).ready(function(){ $(".btn-remove-item").click(function(){ this.parentNode.removeChild(this); }...

Should I use document.createDocumentFragment or document.createElement

I was reading about document fragments and DOM reflow and wondered how document.createDocumentFragment differed from document.createElement as it looks like neither of them exist in the DOM until I append them to a DOM element. I did a test (below) and all of them took exactly the same amount of time (about 95ms). At a guess this could...

Any Ruby models to traverse DOM's quickly?

Does anyone know of any Ruby libraries/gems that allow you to traverse a DOM quickly? I need something which is fast, and doesn't have a lot of dependencies. I've been trying to use Nokogiri, but I'm concerned with the number of 'bug segmentation faults' I've been getting. ...

I need a tool that allows me to quickly generate html and xquery it

At the moment I have a nice class that generates HTML and allows me to create pages without having to worry about things like closing tags, proper nesting, or clear formatting. The syntax is simple and straight forward, //Create an anchor tag $anchor = new Tag("a", array("name"=>"anchor"); //Create a paragraph $paragraph = Tag::Craft("...

Accessing <span> node in Javascript

I'm trying to write a greasemonkey script that only displays photos with the tags bacon. The site it runs on is written like so: <div class="photos"> <ul> ... <li> <a href="photo1"> <img src="http://somesite.co/photo1.jpg" </a> <br /> <a href="tags_photo1"> <span class="tags">&nbsp;bacon, delicious&nbsp;</span> </a> </li> ... </ul> </...

Enabling domxml in php

I have installed xampp 1.7.3 and the php version is PHP 5.3.1.When iam using the function domxml_open_file() ,it throwing an error Call to undefined function domxml_open_file(). How i can enable DOM in php.Thanks in advance. I canot find 'extension=php_domxml.dll' in php.ini file, so i added extension=php_domxml.dll this in php.ini fi...

insert new DOM between elements

Hi, I have the following part of DOM: <div id="content"> <div id="div-1"></div> <!-- here new DOM --> <div id="div-2"></div> </div> I need to insert new part of DOM between "div-1" and "div-2". How I can do it with jQuery? ...

Xml document to DOM object using DocumentBuilderFactory

Hi, I am currently modifying a piece of code and I am wondering if the way the XML is formatted (tabs and spacing) will affect the way in which it is parsed into the DocumentBuilderFactory class. In essence the question is...can I pass a big long string with no spacing into the DocumentBuilderFactory or does it need to be formatted in ...

Applying DIV/Span tag to a word by specific co-ordinates

Sample HTML Data <body style="width:300px;"> <h3>Long-Text</h3> A simple tool to store and display texts longer than a few lines. The search button will highlight all the words matching the name of objects that are members of the classes listed in searchedClasses, itself a member of the KeySet class. The highlighted words are hyperte...

Java DOM - Inserting an element, after another.

Given the following XML file: <?xml version="1.0" encoding="UTF-8"?> <process name="TestSVG2" xmlns="http://www.example.org" targetNamespace="http://www.example.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; <sequence> <receive name="Receive1" createInstance="yes"/> <assign name="Assign1"/> <i...

Simplify PHP DOM XML parsing - how?

Hi coders! I've spent whole days with PHP's DOM functions but i can't understand how it works yet. :( I have a simple XML file that looks okay but i cannot use it how i think when i've created it's structure. Sample XML fragment: -pages //root element -page id="1" //we can have any number of pages -product id="364826" //we...

Code review: Cross site scripting DOM load event, could this be cleaner?

Source on Github: http://github.com/tschellenbach/Fashiolista-Button/blob/master/buttons.js Blog post explaining the code http://www.mellowmorning.com/2010/08/03/creating-your-own-diggfacebook-liketweetmeme-button/ The current dom load version is rather verbose. I need the domload event because the code detects all a[href] elements i...

jQuerys $.data() vs. DOM Object property

Hi folks, I recently needed to append some data to dynamically created LI elements. In my first instance, I used .data() in a way like var _newli = $('<li>foobar</li>'); _newli.data('base', 'ball'); // append _newli to an `ul` that.. was terribly slow. This logic happens in a loop which can easily grow up to 500+ items, it took ages!...

Fetching xml with GM_xmlhttpRequest

I'm trying to retrieve a page with greasemonkey and then extract a link from it, inserting the link into the current page. I'm having some trouble with: GM_xmlhttpRequest({ method: "GET", url: "http://www.test.net/search.php?file=test", onload: function(data) { if (!data.responseXML) { data.responseXML = new DOMParser...

Need Assistance Parsing HTML With PHP

Hello All I am "attempting" to scrape a web page that has the following structures within the page: <p class="row"> <span>stuff here</span> <a href="http://www.host.tld/file.html"&gt;Descriptive Link Text</a> <div>Link Description Here</div> </p> I am scraping the webpage using curl: <?php $handle = curl_init(); ...

Auto expanding textarea

When a textarea has more text in it than can be shown it will display scroll bars. How can I make it so that the textarea will expand itself when it has more text than it can display. My goal is never to have scroll bars appear. A jQuery solution is preferred. ...

JavaScript: Detecting/intercepting insertion of <img> into DOM

We're using a third-party analytics reporting script provided by this analytics company. It adds a 1x1 pixel image into the DOM with reporting data in the URL of the image. Is there any way for me to monitor the DOM and intercept this <img> element and change its "src" attribute before the browser requests the image? Sounds like a real...

Event bubbling jqeury .delegate() or .live() after click event

Hi all, I've tried so many different possibilities to achieve what I feel like should be a simple code execution. I am loading DOM objects from the server via .load(). One of the loaded items is an input text box with a date in it. I want to load the jdpicker (a plugin datepicker) when I click on the input box. Due to the behavior of .li...

Moving a DIV element to bottom of parent (as last child)

I'm trying to create a continually rotating banner for the top of the homepage of a site I'm developing. The best way that I can figure to keep it constantly in rotation is to take the first DIV (firstChild) and move it to the end of the stack once it's slid out of view. This: <div id='foo0'></div> <div id='foo1'></div> <div id='foo2'>...

using XML with PHP

I've got a little problem with an XML file. I need to take the content of the tags (in the XML file) and save them in a MySql data base , using PHP . My supervisor asked me to use DOM, but everything I do isn't workin'. My XML file looks like this : <?xml version="1.0" encoding="windows-1252"?> <BIENS> <BIEN> <CODE_SOCIETE>0024</CO...