dom

DOM and Javascript

I let a user reconfigure the location of a set of rows in a table by giving them ability to move them up and down. The changes are done by swapping nodes in the DOM. After the user has moved rows around, when I do a view source, I see the HTML in the original state (before the user made any changes). Can someone explain why that is? ...

Does visibility affect DOM manipulation performance?

IE7/Windows XP I have a third party component in my page that does a lot of DOM manipulation to adjust itself each time the browser window is resized. Unfortunately I have little control of what it does internally and I have optimized everything else (such as callbacks and event handlers) as much as I can. I can't take the component of...

Does javascript cache DOM elements?

I'm using mootools to toggle the display (and existence) of two DOM elements in one of my forms. Then, I am using javascript to validate the form to make sure that all of the required fields were filled in. The problem is that the the browser seems to be caching the elements. For example, I have html like this: <input name="inputbox"...

Finding the id of a parent div using Jquery

I have some html like this: <div id="1"> <p> Volume = <input type="text" /> <button rel="3.93e-6" class="1" type="button">Check answer</button> </p> <div></div> </div> and some JS like this: $("button").click(function () { var buttonNo = $(this).attr('class'); var correct = Number($(this).attr('rel')); ...

How can a object self destruct on an event, in javascript?

I have this function, to create a DIV on-the-fly. But now, I want to destroy this object on onclick event, but I just don't know how. function creatediv(id) { var newdiv = document.createElement('div'); newdiv.setAttribute('id', id); newdiv.onclick=function(){this=null;}; //bad function document.body.appendChild(newdiv...

Focus on a non-input/anchor element?

I'm working on some JavaScript that requires a tag that can get focus. I'd like to be able to use a <div /> tag, however <div /> tags can't get focus. It looks like the only elements that can gain focus are <input /> tags and <a /> tags. Is there any other way to allow an element to gain focus that isn't an <input /> or <a /> tag? I ca...

how to overcome IE bug when dynamically attaching div to body from script

UPDATE: the HTML was not well formed. This was causing the script to appear in inner div. Please ignore the question. IE ver<8 has a known bug (Internet explorer cannot display the page. Operation aborted) If a script tries to append something to upper level block: The bug is described here: Update: I rephrased the question and simp...

Fade In/Out and create/hide <DIV> with javascript

Hi I'm creating some on runtime. For that I'm using this function: function creatediv(id, html, left, top) { if (document.getElementById(id)) { document.getElementById(id).style.display='block'; fadeIn(id, 300); } else { var newdiv = document.createElement('div'); newdiv.setAttribute('id', id); ...

javascript/dom -- how expensive is creating vs rearranging dom nodes?

Hello, I'm trying to optimize a sortable table I've written. The bottleneck is in the dom manipulation. I'm currently creating new table rows and inserting them every time I sort the table. I'm wondering if I might be able to speed things up by simple rearranging the rows, not recreating the nodes. For this to make a significant differen...

Creating an XML string in Flex (AS3) by using DOM functions

I want to create an XML string in Flex 3 in a similar way to you might approach it in Java. I only want a small piece of XML in the format <slide thumb="http://www.thumbs.com/thumb.jpg" type="static" blah="bleh" /> The only type of code I can find for doing this seems ridiculous.... private function createXML(): void { var xm:XML = <...

JQuery methods and DOM properties

I am confused as to when I can use the DOM properties and when I could use the Jquery methods on a Jquery object. Say, I use a selector var $elemSel = $('#myDiv').find('[id *= \'select\']') At this point, $elemSel is a jquery object which I understand to be a wrapper around the array of DOM elements. I could get a reference to the DO...

Are events lost in jQuery when you remove() an element and append() it elsewhere?

What happens in jQuery when you remove() an element and append() it elsewhere? It appears that the events are unhooked - as if you were just inserting fresh html (which I guess is what happening). But its also possible my code has a bug in it - so I just wanted to verify this behavior before I continue. If this is the case - are there...

jquery wait cursor while loading html in div

I want to show to the user a state that the result is loading. How can I change cursor or gif while loading result in div with $MyDiv.load("page.php") ? ...

This DIV is not shown on Internet Explorer

Hi I need to do some alert-message (like validations, etc), and I'm doing that with DIV. This is how I'm doing the validation: <form action="index.php" method="post" onsubmit="return validateSearchKeyword();"> <input class="text_search" id="text_search" name="text_search" type="text" value="pesquisar" onfocus="if (this.value=='pe...

How to move div with the mouse using jquery ?

I need to be able to move a div with my mouse and store the new pos of the div in database to remember the display. How can I do it? ...

PHP: Check SimpleXmlElement for erros

Anyone know how can I check the php SimpleXmlElement Object for errors?I mean if is an valid XML file?I have read the manual a lot..but i don't get it! Best Regards, ...

jQuery parents() and parent().parent() only see one level up?

Hi All, I am having some issues with getting the list of parents of an element with jQuery. Perhaps I am missing something, but I have a link inside several nested divs, and am trying to get a list of siblings of the parent's parent. I only seem to be able to go one level up from the link though, so I can't The HTML is as follows: <...

What Cross-Browser issues have you faced?

While developing for multiple sets of browsers, what issues have you faced while development due to differences in browser implementation? To start with I am listing some of those which i faced: A text node in Firefox allows only 4K data. So an XML Ajax response gets split up into multiple text child nodes instead of only one node. It...

Changing CSS Values with Javascript

It's easy to set inline CSS values with javascript. If I want to change the width and I have html like this: <div style="width: 10px"></div> All I need to do is: document.getElementById('id').style.width = value; It will change the inline stylesheet values. Normally this isn't a problem, because the inline style overrides the style...

Is there any way to track selection range in iframe's designMode?

Hi, I've been experimenting with this for a while but didn't get anything working well — is there any way to track mouseups and selections in iframe's designMode, preferably in a cross-browser compatible mode? ...