?
Solved

get all images in <tag id=myid>

Posted on 2008-11-01
3
Medium Priority
?
495 Views
Last Modified: 2010-04-21
hi experts,

I am trying to use the same Code Snippet  but insted of looking in the entire document, I only need to look  inside  <tag id=myid>,

reagrs,
for(var i=0; i< document.images.length; i++) {
	if(document.images[i].parentNode.tagName == "A")
          setupRollover(document.images[i]);
}

Open in new window

0
Comment
Question by:uk1900
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 15

Accepted Solution

by:
Tomarse111 earned 1000 total points
ID: 22858270
Feed the following function your id and it will return all of the images within that parent:
<script>
function getImgs(id){
	var children = document.getElementById(id).getElementsByTagName('img');
}
</script>
 
 
//So for example, feeding getImgs id 'doc' returns a collection of 3 images
<body id="doc">
	<img id="a" src="" />
	<img id="b" src="" />
	<a href="" id="d">bob</a>
	<img id="c" src="" />
	<input type="button" onclick="getImgs('doc');">
</body>

Open in new window

0
 
LVL 18

Assisted Solution

by:Pawel Witkowski
Pawel Witkowski earned 1000 total points
ID: 22859655

for(var i=0; i< document.getElementById('myid').length; i++) {
        if(document.getElementById('myid')[i].parentNode.tagName == "A")
          setupRollover(document.getElementById('myid')[i]);
}

Open in new window

0
 

Author Closing Comment

by:uk1900
ID: 31512355
thx man
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question