How do I select the h3 tag inside a div? (prototype.js)

<div id="indivpost1">
	<img src="th-1.jpg" />

Open in new window

Shouldn't this work?
$$('#indivpost1 h3')

Open in new window

Please tell me what I'm doing wrong.
Who is Participating?
leakim971Connect With a Mentor PluritechnicianCommented:
To get the first one : $$("#indivpost1 h3").first();

Test page :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" src=""></script>
<script language="javascript">
	Event.observe(window, 'load', function() {
		alert( $$("#indivpost1 h3").first().innerHTML );
<div id="indivpost1">
	<img src="" />

Open in new window

your tag says javascript, but it looks like you are looking for JQuery maybe?

I don't use JQuery, but in Javascript it is:

var myDiv = document.getElementById('indivpost1');
var myTag = myDiv.getElementsByTagName('h3');

This will get you all h3 tags within that element.
ram0nmAuthor Commented:
Thanks for your help but I'm using Prototype not jQuery.
>>$$('#indivpost1 h3')
This should return an array with one element (with your example)
try breaking it down
$$('#indivpost1') .find('h3');
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.