GetParentObject

Description

This JavaScript function gets the first occurrence of the tag specified in the HTML ancestry of the passed object.

Syntax

getParentObject(obj, tag)

Input parameters

obj - Required. Handle to an object in HTML object hierarchy.

tag - Optional. String containing the name of the ancestor node used in a search. If not passed, the function returns null.

Return values

The first occurrence of the tag specified in the HTML ancestry of the passed object.

Example

This example shows how to code a client-side deletion to run when the user selects a Delete icon in a table row. In this example, element refers to the object that the user selects.

function deleteRow(element) {
	var row=getParentObject(element, "TR");
	oTable=getParentObject(row, "TABLE");
	row.parentNode.deleteRow(row.rowIndex - 1);
	fireRowsChanged(oTable);
	return false; 
}