Tech Journal Back to Tech Journal

What's the cross-browser JavaScript/JScript method of getting objects and attributes in DHTML?

You can use document.getElementById("name") to get any item with the given ID. And also object.getAttribute("name") to get custom-set properties/values in HTML elements. (See symChyp for example!)

So if you have a code like

<DIV ID="myDiv" myAttrib="values"></DIV>

You can use these values to access them:

var mydiv = document.getElementById("myDiv");
var attrib_value = mydiv.getAttribute("myAttrib");
Last updated on 2004-10-15 15:00:00 -0800, by Shalom Craimer

Back to Tech Journal