Web Design Forum: how can i call element +js - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

how can i call element +js

#1 User is offline   hosam alaa 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 26
  • Joined: 28-October 08
  • Reputation: 0
  • Gender:Male
  • Location:EGYPT
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 24 January 2012 - 12:04 PM

hello
i have a simple question

lets say i have this code

<div id="myid">
<a href="#">link</a>
</div>

well..
inside the JavaScript i can call the div using document.getElementById("myid")
but i want to call the <a></a> which is inside this div
i want to call the link not the div and i don't have the link name or its id

thanks
0

#2 User is online   Skateside 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 465
  • Joined: 09-November 08
  • Reputation: 44
  • Location:Bedford
  • Experience:Advanced
  • Area of Expertise:Coder

Posted 24 January 2012 - 12:19 PM

Once you have the DIV, simply find all As within it:
var div = document.getElementById('mydiv'),
    a = div.getElementsByTagName('a')[0];

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users