Jump to content

[SOLVED] Searching through html/css with javascript


therealwesfoster

Recommended Posts

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!

Link to comment
Share on other sites

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

 

???

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.