属性的应用,点击按钮,出现效果

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="jquery-1.7.2.js"></script>
<script type="text/javascript">
//$(function(){})相当于window.onload(){}代码写在{}里面
$(function(){
//$("button")选取所有的button
$("button").click(function(){
alert("hello word!!");
//弹出自身的文本值
alert($(this).text());
//获取button标签
var $btn = $("button");
//获取id为btn的标签
//var btn = document.getElementById("btn");
//弹出所有的button的文本值
alert("---"+$(btn).text());
});
})
</script>
</head>
<body>
<button id="btn">clickme</button>&nbsp;&nbsp;&nbsp;
<button>youarenotmyonlyone</button>
</body>
</html>

posted @ 2016-10-19 16:18  caocx  阅读(329)  评论(0编辑  收藏  举报