JavaScript Tutorial/Dojo toolkit/byId
Add action to tag by using dojo.byId("id")
<html>
<head>
<script type="text/javascript">
var djConfig = {
baseScriptUri : "js/dojo/"
};
</script>
<script type="text/javascript" src="js/dojo/dojo/dojo.js"></script>
<script language="JavaScript" type="text/javascript">
function setup() {
dojo.byId("outerDiv").onclick = doOuterClick;
dojo.byId("innerDiv").onclick = doInnerClick;
}
function doOuterClick(e) {
alert("out");
}
function doInnerClick(e) {
alert("inner");
dojo.stopEvent(e);
}
</script>
</head>
<body onLoad="setup();">
<div id="outerDiv">
outer
<div id="innerDiv">
inner
</div>
</div>
</body>
</html>
Get Element by id
<html>
<head>
<script type="text/javascript">
var djConfig = {
baseScriptUri : "js/dojo/"
};
</script>
<script type="text/javascript" src="js/dojo/dojo/dojo.js"></script>
<script>
function testIt() {
alert(dojo.isDescendant(dojo.byId("div3"), dojo.byId("div1")));
}
</script>
</head>
<body onLoad="testIt();">
<span id="div1"></span>
<span id="div2"><span id="div3"></span></span>
</body>
</html>