第02章 基础核心

index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>基础核心</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="demo.js"></script>
</head>
<body>
<div id="box">基础核心</div>
</body>
</html>

demo.js

/*
$(function(){
	$('#box').css('color','red');
});
jQuery(function(){
	jQuery('#box').css('color','red');
});
alert($===jQuery);//相等、恒等

$().css('color','red');

$(function(){
	alert($);//jQuery 对象的内部
	alert($());//返回的 jQuery 对象
	alert($('#box'));//返回的也是 jQuery 对象
	alert($('#box').css('color','red'));//还有返回的 jQuery 对象
	$('#box').css('color','red').css('font-size','50px').css('font-weight','bold');
});

$(function(){
	alert($('#box'));//[object Object],返回的 jQuery 对象
	alert(document.getElementById('box'));//[object HTMLDivElement],原生 DOM 对象
	alert($('#box').get(0));//[object HTMLDivElement]
	alert($(document.getElementById('box')).css('color','red'));//jQuery 对象和 DOM 对象之间的互换
});

jQuery.noConflict();//自行了断,把自己的 $ 所有权剔除 
jQuery(function(){
	alert(jQuery('#box').get(0));
});

$(function(){
	alert($('#box').get(0));
});

*/

猜你喜欢

转载自onestopweb.iteye.com/blog/2223431
今日推荐