dom

jQuery hover over child elements makes quirky effects

Hi I've got this markup (simplified): <div class='item'> <a> one link </a> <a class='trash'><img src='trash.png'/></a> </div> I'm highlighting the div when the mouse enters, and showing the (otherwise hidden) 'trash' link (it's like a tiny trash bin) so the user can delete the link. I can't use 'hover' effect, because I need the...

using getElementById to retrieve styless in CSS

Why is the first alert box empty, but the second one says 100px? I'd expect the first box to say 300px.. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head> <meta http-equiv="Content-Type" content="text/html...

How to get nodes in first level using PHP DOMDocument?

I'm new to PHP DOM object and have a problem I can't find a solution. I have a DOMDocument with following HTML: <div id="header"> </div> <div id="content"> <div id="sidebar"> </div> <div id="info"> </div> </div> <div id="footer"> </div> I need to get all nodes that are on first level (header, content, footer). hasChild...

Detect for website change via javascript / jquery

Is it possible to check if the browser user has opened a new tab, is closing (not minimizing) the current tab/page, or changing the url? Don't worry, nothing suss it's just for a novelty website. Could someone let me know if this is/isn't feasible via javascript (preferably jquery), and if so, what method to look into. Thanks EDIT: In t...

creating an element and setting its attribute with jQuery

Hello all, I'm trying to create an <ol> element with jQuery and set its class and id attributes. Is there any way to do this all at once? None of my ideas have worked so far, I'm still very new to jQuery... ...

What are the issue with putting markup outside <body> ?

I have a bookmarklet storing a lot of DOM data, but I would love to avoid to put them out of the body tag so the script in the page won't mess with it. Semantic value is not an issue for once, but I would like to know : will it trigger some browser behaviour ? will it still be accessible in the DOM ? can I display it using absolute po...

Cross window js interaction between a popup and another window of the same domain

i'm opening a popup from window a of http://example.com. then close window a and open another window b with same domain, http://example.com. ıs it possible to access popup's DOM from window b and how? popup is opened from window a by window.open('http://example.com/blah', 'somename', settings..), executing the same from window b with di...

Jquery unwrap() method?

There is a great method in jquery called wrap() that will wrap a selected element inside a new element, like so: Start with: <p>I wish I was wrapped!</p> Add code: $("p").wrap("<div></div>"); End with: <div><p>I wish I was wrapped!</p></div> But what I need is something that will unwrap, so that the above process is reversed....

onchange event doest not bubble in MSIE. Where do I find a chart listing all such events.

I just found out that onchange event does not bubble in MSIE. I hopped to http://www.quirksmode.org/ to see if I could find other events which are not supported by IE. However I do not see any chart listing onchange event as an event that does not bubble in MSIE. Where can I find such a char? ...

calling function based on dom change

I rewrote a bit of my code based on that it's not really feasible to check to see if a javascript variable changes. But, how would I do it with a dom element? For instance <div id='foo'>123</div> <script> $('#foo').html('456'); // function gets fired since #foo changed. </script> I tried $("#foo").change(function () { alert('ch...

Adding elements to the DOM using appendChild then referring back to the class that created them

How do you go around adding an element to the DOM which still knows which instance of an object created it so that it can refer back to the class later on? Basically the following code should allow you to add one or more photo albums to a page, where Javascript generates all the DOM elements needed. I.e. in the following code example i...

How do I find out the DOM node at cursor in a browser's editable content window using Javascript?

I am looking for a solution that works cross browser i.e. IE, Firefox and Safari. ...

Google Maps not functioning for me

Hey all, My Google maps code is all squared away and valid, but it doesn't load on the page. Here is the page in question, I have full availability to code, not sure why it's breaking: http://whs.rjuhsd.us/calendar/map The Gmaps JS is in the header, with the correct key. Sensor is set to true, and the element is defined in the documen...

How to get clone of HTML, modify it, get HTML string without affecting DOM?

I have some HTML code like this: <div style="background:red;width:900px;height:200px" id="wrap"> <div id="inner" style="width:300px;float:left"> ... </div> </div> I need to: 1) Remove "styles" attribute and maybe some others 2) Leave only "id" attribute 4) Get resulting HTML as a string 5) All of this without affect...

dom doc to string

I have a method in java that has 2 String parameters and it writes string to a file, now I have dom doc that holds value that I need to write to a file but its not string type, how can I convert it to a string here is my code : import java.io.*; import org.w3c.dom.*; import org.xml.sax.*; import javax.xml.parsers.*; import javax.xml.tr...

browser textbox autocomplete event, when does this happen?

If i dont put autocomplete="off" on my <input type="text" />s the browser will sometimes fill them in with likely/remembered data. When does this happen in the DOM-load-lifecycle? It appears to be after: $(function(){ alert('i happen before autocomplete'); }); Is there a dom-load event which occurs after form-autocompletion? If s...

Updating a nextSibling element

I have been trying to make something work with JQuery. I have the following function: <script type="text/javascript"> $(function(){ // start a counter for new row IDs // by setting it to the number // of existing rows var newRowNum = 2; // bind a click event to the "Add" link $('#addnew').click(function(){ ...

How do I find the DOM node that is at a given (X,Y) position? (Hit test)

I have the coordinates (X,Y) of a point in an HTML document. How do I determine what DOM node is at those coordinates? Some ideas: Is there a DOM hit test function that I missed, that takes a point (X,Y) and returns the DOM element there? Is there an efficient way to walk the DOM element tree to find the containing element? This seems...

jQuery: Move Table Row?

Say I had to links with up/down arrows for moving a table row up or down in order. What would be the most straightforward way to move that row up or down one position (using jQuery)? There doesn't seem to be any direct way to do this using jQuery's built in methods, and after selecting the row with jQuery, I haven't found a way to then ...

Tinymce IE6+ How can I get a working range?

I've searching forever trying to figure out why IE will not save the current caret position and then reload it. To be descriptive of the situation it works like this: Client wants Tinymce custom built with an ajax image loader that is simplistic in the nature that any "idiot" can upload and set some settings to an image within the text...