therealwesfoster Posted December 5, 2007 Share Posted December 5, 2007 Here's my question.. I have some text in a webpage in between < b > tags, inside of a < div >. now, the div has an ID of "div".. <div id="div"><p>bla bla bla</b><br><b>hey there</b></div> can I acces the <B> tag like this? var it = document.getElementById("div").b if not, how would I access something like that with CSS inheritance? (example, html.body.div.b) ------- Ok, that was Q number 1. Here's #2. How can I search within a HTML file? for example, if I wanted to get a certain URL location, i would search for < a href ="HERE.html">fff and would be able to store HERE in a JS variable.. I hope that makes sense.. thanks! Quote Link to comment Share on other sites More sharing options...
fenway Posted December 5, 2007 Share Posted December 5, 2007 You want to look into DOM nodes and children. Quote Link to comment Share on other sites More sharing options...
therealwesfoster Posted December 5, 2007 Author Share Posted December 5, 2007 Alright ive been reading up on that.. here's what i have.. i want to get the text of the 11th occurance of the < font > tag html: <font class="green">TEST TEXT</font> javascript: alert(document.getElementsByTagName('font')[10].firstChild); but it returns (in an alert window) [object Text] but it should say TEST TEXT ??? Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 5, 2007 Share Posted December 5, 2007 <script language="javascript"> function getText() { alert(document.getElementsByTagName('font')[0].innerHTML); } </script> </head><body onload="getText()"> <font class="green">TEST TEXT</font> document.getElementsByTagName('font')[10].firstChild = will give you the 10th instance of the font tag. Quote Link to comment Share on other sites More sharing options...
therealwesfoster Posted December 6, 2007 Author Share Posted December 6, 2007 so simple.. big thanks man, i really appreciate it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.