标签:function world button title
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-1.7.2.js"></script>
<script type="text/javascript">
$(function(){//相当于window.onload
$("button").click(function(){
//alert("Hello world!!!");
alert($(this).text());
//JQuery对象和DOM对象
//获取一个JQuery对象
var $btn = $("button");
//JQuery对象是一个数组
//alert($btn.length);
//可以通过数组的下标转为DOM对象
//alert($btn[0].firstChild.nodeValue);
//由DOM对象转为JQuery对象
var btn = document.getElementById("btn");
//alert($(btn).text());
//$("#id") document.getElementById("id");
//$("tagName") document.getElementByTagName("tagName");
});
})
</script>
</head>
<body>
<button id="btn">click me1</button>
<button>click me2</button>
</body>
</html>本文出自 “阿凡达” 博客,请务必保留此出处http://shamrock.blog.51cto.com/2079212/1564872
标签:function world button title
原文地址:http://shamrock.blog.51cto.com/2079212/1564872