Monday, April 27, 2009

JavaScript function to get element using tag name and title

function GetElementByText(tagName, title)
{
var a = document.getElementsByTagName(tagName);

for (var i=0; i < a.length; i++)
{
if (a[i].value)
{
if (a[i].value == title )
{
return a[i];
}
}
}
return null;
}

No comments: