<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<!--下面的语句是对YUI种子文件的引用-->
<script src="http://yui.yahooapis.com/3.9.0/build/yui/yui-min.js"></script>
<script>
YUI().use('node', function (Y)
{
var helloWorld =
function(e)
{
e.target.setHTML("<p>Hello World!</p>");
e.target.setStyle('background-color', 'orange');
};//函数helloword的声明
var myDiv = Y.one("#container");//Y.one()元素选择器,匹配元素为id="container"的元素
myDiv.on("click", helloWorld);//用Node类的on方法对myDiv监听事件click,触发函数helloword
});
</script>
</head>
<body>
<div id="container" style="width: 1000px; height: 100px; background-color: pink;">
<p style="margin-top: 40px; padding-top: 40px; padding-left: 40px;">Click for Hello World test.</p>
</div>
</body>
</html>
YUI学习
最新推荐文章于 2018-10-18 15:21:47 发布