var myarray = ["aaa", "bbb", "ccc", "ddd"];
var myelement = document.getElementById(elementID);
if (myarray.indexOf(myelement) > -1)
{
myelement.scrollIntoView(true);
myelement.focus();
}
else
{
alert("Hello, chimpworld!");
}
Note that some older browsers don't support indexOf (for example IE 6, 7, 8)
No comments:
Post a Comment