dojo事件绑定

1.<html> 
<body> 
<input id="btn" type="button" value="hello" /> 
<script> 
document.getElementById("btn").onclick=sayHello; 
function sayHello() { alert('Hello'); } 

</script> 
</body> 
</html>

2.<script>
dojo.require("dojo.parser");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.Button");
function init()
{
dojo.connect(dojo.byId("mybutton"),"onclick","login");//绑定事件
}
function login()
{
if(dojo.byId("myname").value=="goodguy" &&
dojo.byId("mypassword").value=="goodgoodstudy")
alert("Dojo World welcome you!");
else
{
alert("Dojo does not like you!");
}
}
dojo.addOnLoad(init);//相当于onload
</script>

UserName:
<input type="text" length="20" id="myname" dojoType="dijit.form.TextBox">
<br>
PassWord:
<input type="password" length="20" id="mypassword" dojoType="dijit.form.TextBox">
<br>
<div id="mybutton" dojotype="dijit.form.Button">Submit</div>

 

你可能感兴趣的:(职场,dojo,休闲,事件绑定)