473,396 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DOM get Element Content

bilibytes
128 100+
Hi,

I am trying to get the content of an element and reuse it elsewhere in the script

lets say i have:

Expand|Select|Wrap|Line Numbers
  1. <div id="content">
  2.    <ul name="subcontainer">
  3.       <li name="header"><h3>Title</h3><h4>Text here...</h4></li>
  4.       <li name="image"><img class="foto" src="3396/2.jpg"/></li>
  5.       <li name="listcontent">Text Here...</li>
  6.       <ol name="language">
  7.          <li><img src="/images/es.gif" alt="es"/></li>
  8.       </ol>
  9.    </ul>
  10.    <ul name="subcontainer">
  11.       <li name="header"><h3>Title</h3><h4>Text here...</h4></li>
  12.       <li name="image"><img class="foto" src="3396/2.jpg"/></li>
  13.       <li name="listcontent">Text Here...</li>
  14.       <ol name="language">
  15.          <li><img src="/images/es.gif" alt="es"/></li>
  16.       </ol>
  17.    </ul>
  18. <div>
  19.  
Ok so what i want to do, is tu reuse the code contained into the Element named "subcontainer".
The point is that there are multiple of those. I am able to target the one that i need (in fact, it is the one that the user clicks on).
Once i have the <ul> element under a variable (named: selectedNode), i would like to be able to somwhere say:

[HTML]document.getElementById("content").innerHTML.selec tedNode;[/HTML]

The problem is that this will return an object, and will not print the content of the node, as i want it to do.

My question is,
Is there a way to access the selectedNode's content, assuming that the content is compound by multiple nodes and different levels of nodes?

thankyou very much

bili
Oct 24 '08 #1
3 11885
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("content").innerHTML.selectedNode;
should be

Expand|Select|Wrap|Line Numbers
  1. document.getElementById("content").innerHTML = selectedNode;
Oct 24 '08 #2
bilibytes
128 100+
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("content").innerHTML.selectedNode;
should be

Expand|Select|Wrap|Line Numbers
  1. document.getElementById("content").innerHTML = selectedNode;
Yes you are right, and it is this way in my script, i miscopied this bunch of code, but this is not the problem,
with the code you wrote, it will return[ListTypeObject] and what I need is to reuse the list with all its contents in another part of the script.

I don't know if i have to parse the whole list creating variables with each node or if there is a shortcut that would allow me to take all the list content and do:

Expand|Select|Wrap|Line Numbers
  1. document.getElementById("content").innerHTML = selectedNode;
[/quote]

Thanks any way
Oct 24 '08 #3
bilibytes
128 100+
it was appendChild!
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("content").appendChild(selectedNode);
[/quote]
Oct 24 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Imiro | last post by:
Hi, Trying to validate this dtd example with xml-spy 5 pro: This works: <!ELEMENT note (#PCDATA|body)*> <!ELEMENT body (#PCDATA)> This doesnt: <!ELEMENT note (#PCDATA|body)>
6
by: Wole Ogunremi | last post by:
I guess this is a well asked question but it is tripping me up! I'm putting a forum together allowing xhtml markup content. I am validating against a schema but getting "Could not find schema...
8
by: Knighterrant | last post by:
I want to copy elements from one namespace to anothor, how to create the xslt? for example, the source data is: <s:mail xmlns:s="urn:source-namespace"> <s:subject>xxxx</s:subject>...
2
by: pawel.pabich | last post by:
Hajo, I know only one way of forcing element to have one or more childes: <xs:element name="saleOrSupplyMethod"> <BR/> <xs:complexType> <xs:choice> <xs:sequence> <xs:element...
0
by: ruediger | last post by:
Hi there, I want to set up an XML Schema for documents of the following structure: The <root> node contains - an optional <message> element with a text attribute, and - arbitrary further...
13
by: Jiho Han | last post by:
Here's the issue. You have a class, Class Person { public int id; public string firstname; public string lastname; }
8
by: VK | last post by:
Can be multiple instances of element used as the root element? That's a curly way of asking, but I did not come up with a better sentence, sorry. What I mean is with a document like: <?xml...
6
by: Lord0 | last post by:
Hi there, How do I define in a schema that an element (<element>) may have any content i.e. text, other elements, partial elements, angle brackets etc? So all of the following would be valid:...
1
by: DrDavey | last post by:
What are the advantages/disadvantages of using a choice of a several "sub-"elements with empty content (and no attributes) vs. simple content. Here's an example: Using simple content:...
0
by: joeller | last post by:
On October 13, 2006 Mark Rae wrote Hi, Firstly, I have not the slightest intention of using framesets - the reason for this post is merely to ask for assistance in furthering my understanding of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.