Getting Elements And Contents Of A Subset Of The Document
Apr 12, 2006
In my document I have a table row with an unknown number and type of elements. I want to make a set of name-value pairs contained in this table row, while I do not know the names of the elements in advance.
Is there something like "give me all children of this table row"? Can I get all children in the document with a wildcard 'Subname*', like give me all elements starting with 'Subname'?
It's for an Intranet so the browsers could only be IE 6.
I have a contact info form with about 16 fields. I need to hide a subset of fields for address when the end user either (1) tabs out of the subset group, (2) clicks anywhere outside the subset field group.
I do not want to hide the fields when the end-user is tabbing within the subset of address fields, yet the focusout handler is triggered when it shouldn't be.
I am trying to make a front page that is a dashboard much like the BBC website. I am constructing the widgets using block elements and the contents vary from widget to widget. I can get the items to drag, drop and toggle slide using JQuery UI, however I want the user to be able to customize their placement and remember them in a cookie for the next visit.
The closest thing I have seen and tried is using sortables but that can only be achieved with list items and in turn invalidates my code when trying to put a div or table elements there. Is there a work around for this? I've tried looking at the code of the BBC site and it appears that the widgets get rendered after the the page is loaded (as it does validate as XHTML Strict).
I have this script that will read all the headers (h1-h6) in your HTML document and also HTML comment tags which are specially recognized, and it will create an HTML document "table of contents" (or outline) and insert it as a DIV within the document. This is for people with ESPECIALLY LONG HTML documents...it makes sense for this purpose.
The script is attached to this post in a zip. The zip archive has four JS files. 'htmlTOCgenerator.js' has all the meat of getting the nodes and generating the DOM nodes for the ToC. The other three have 'support' functions and are included. The 'colorContrasting.js' file is actually supposed to compute 'complementary' colors from random color generation. Why? Refresh the document each time, and the ToC has a different foreground (text) and background color, that's why. Breaks up the monotony. A large comment block inside 'htmlTOCgenerator.js' tells the document maker how to set up the HTML document for making this work.
In a first version, this script inserted the ToC ('table of contents') at the top of the document where the HTML comment tag "<!-- putTOChere -->" was placed/found.
Then I decided it was better to place the ToC DIV element to the left of the text, in a fixed block (does not scroll with text). The ToC DIV contents themselves are scrollable in case the contents would go beneath the bottom of the client window height--can't have that.
Click here to see an example of how it works:
I am having problems with it though.
1. The scrollbar on the ToC block always shows, even if the contents don't fill up the block. The CSS is set for 'overflow-y:scroll' but that does not mean the scrollbar does not show if there is no overflow. It would be nice to control that. Still have not figured it out.
For an example of not enough headers to fill out the height-specified (by necessity) fixed DIV block, see this page.
2. In my documents, the main body of text is all wrapped in a DIV with its right- and left-margins set to 'auto', so that when user widens or narrows the client window, the text is always centered. I need to stop the main body text from running behind the TOC during a narrowing of the client window. I thought setting the right margin of the ToC DIV should stop that. Anyway, that is a CSS styling problem, I suppose, although the CSS must be set through script (I do through script since the instructions don't require the document maker to set up CSS: too many instructions become annoying for anyone wanting utility in the script). And if you think frames are answer, that complicates matters and I believe it gets away from the eventuality when frames are deprecated.
3. I also want criticism on how to make this presentation/structuring/interaction of the ToC block better or workable.
How to find various elements in the document with jQuery?
Example.
I want to find two tags - <span> and <p>.
I'm trying to use jQuery.find, but he search of one in one.End does not return what elements were found, and how many were. And how do you know which elements have been found?
Is it possible to manipulate with elements in a variable, instead of in the document? I have a situation where I'm getting some HTML code in an Ajax response, but I want to make changes to it before I put it in the document. So I would need to iterate through some elements and change their attributes while the HTML code is still in the variable and then write it to the document.
I have some fixed or absolute positioned DOM elements in the whole document for some purpose, How can I traverse the whole document to get the above mentioned elements, any jquery method to be there please let me know,
I use the following code to add a "click" behaviour to an element:
$(document).ready(function(){ $("#element_id").click (function(){ ...... do something ....
[Code]....
Part of the node I clone is the element from the first piece of code I quoted. The addRowJob function also changed the ID of every element in the node I cloned. This way all IDs remain unique. Lets say the element in question has the ID "#element_id". Now I clone the node (which includes the element) and the cloned element gets its ID changed to "#element_id_new".
Of course I now want this newly append element ("#element_id_new") to have a click event attached to, but even if extend my $(document).ready(function() to:
$(document).ready(function(){ $("#element_id").click (function(){ ...... do something .... });
[Code].....
I simply doesn't work for the appended element.
My guess is that the $(document).ready(function(){ only fires when the document is finished loading. At this stage there is no element with the ID "#element_id_new" and therefore the click event can't be attached to the element. Makes senses...
But how do I get this click event attached to the newly appended element with the ID "#element_id_new"?
I'm still struggling with creating a properly formatted form. This problem it two-fold. The first part isn't strictly a javascript problem, but I've included it here because it relates to the second part, which is:
1. Given the form below, how should I structure the input names to get an array like that at bottom?
2. The scripts are used to provide running totals and subtotals. They're fun - try them! But how should I modify these scripts so that they can continue to work with the amended naming policy?
I want to load an html div in a variable, modify it in another variable; and then change the document injecting the contents.
1. I load the html to be changed in a variable (code) 2. I modify an attribute of <param> using attr() and I put the result in a var (newcode) 3. I change the html in the doc
I've used the debugger, and all steps give the expected results, except of newcode.html(), which is a null string. Why?
I'm looking for javascript to analyze the contents of a textbox and replace the contents with the appropriate date. To make that a little clearer, if the user types 'tomorrow' then when they tab/move onto the next text box the 'tomorrow' text should be replaced with the date for tomorrow in the format dd/mm/yyyy, if the user enters '1 week' then the text should be replaced with the date in one week in the format dd/mm/yyyy etc.
Let's say I have a webpage. The user does something that writes some new HTML code in to the document, code that wasn't there on the initial page load. This new code causes new HTML elements to appear on the page.
Is there any way I can access the new HTML elements thought JQuery?
Standard use of $('#newelement').click(whatever) doesn't appear to work on HTML code generated by an AJAX request. It's like the JQuery "can't see it".
I want to get all the "a" elements with the href attribute in this form: [URL] where any can be a string containing just letters and/or numbers. I'm new to regex and XPath so i can't get it right. I digured it out the regex but i'm not sure if it's 100% correct:
Im currently working on a project with jquery... the thing is.. i need to change the contents of a div named "sub2" with the contents of "pets.html"... i've read some tutorials and i thought the best way to do this is through the use of jquery...
Here's my code:
My image which is supposed to be clicked contains this:
The code is working ., but when i transfer my codes to netbeans with Tomcat running the code didnt work ...
Is there anyone here who knows what's wrong or what should i do with my code?
Suppose a HTML document has a iframe. Using javascript,I want to detect ,on load of the html document, whether the body of the iframe document is ready to be displayed.I want to be able to overwrite the the body contents (before it actullay loads) of the iframe.can I do it with jquery? say if ,HTML doc is
Normally an SVG document is loaded/parsed/interpreted inside an HTML document using an 'object' (or 'embed') element, although there are supposedly other ways too. The problem is, the SVG document must be static this way.
I want to use the DOM interface to build SVG dynamically inside an HTML document. I am guessing I can build it inside HTML within an 'object' (or maybe 'iframe'?) element.
My intentions/goals:
In Javascript, I construct an object 'embedSVG' which has properties and methods for creating valid SVG elements and setting their attributes and attribute values.
During construction, the SVG document is created with its root element. During debugging in FF 2.0 (I'll work on an MSIE-compatible format later), I am using the Mozilla DOM Inspector and comparing nodes when the 'object' element is loading a valid external SVG document, and when I am appending the child representing the SVG document created by the DOM functions.
However the child node (#document) does not specify 'svg' as the root element, but instead 'HTML'. Something is not working.
Here is the relevant code in 'ScriptTest.html' which is the HTML in which the SVG is supposed to be embedded. Below it is the relevant code for 'svglib.js' which is supposed to contain code for building the SVG dynamically.
What this code is supposed to do is load the HTML page and execute the anonymous script, and draw a navy blue-bordered yellow rectangle on a blank page. This is similar to the example in the SVG 1.1 W3C Recommendation on page 202 of the 719-page PDF.
I am getting an exception when embedSVG object placeInHTML() method is called: NS_ERROR_DOM_HIERARCHY_REQUEST_ERR. I find in DOM Inspector in spite of or after the exception that a document is placed as a child of the object element, but it is HTML, with a default 'head', 'title', 'body' elements placed.
Determine what the previous page was that the user was viewing, even if the user arrived at my site by through the use of a browser function (history, location bar, refresh, etc.). Is this possible?
I'm not wuite sure how document.history functions - what degree of privacy is given to the user and to what extent can web pages get URLs from the user's history?