jQuery()函数的使用方法

版权声明:版权所有-江西服装学院 https://blog.csdn.net/qq_38263696/article/details/82973441

jQuery()函数的4种调用方法

  1. $(“CSS选择器”,context)
  2. $(Element or Document or Window);//将对象封装为jQuery()对象
  3. $(HTML字符串,{css:{},click:Function ,src:url});
  4. $(Function);
<!DOCTYPE html>
<html>
 <head>
		<meta charset="utf-8">
		<title>this is test</title>
		<script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
</head>

<body>
		<div>1</div>
		<div>2</div>
		<div>3</div>
</body>
</html>
<script>
var divCol_1=$("div",document);
var divCol_2 = $("document");
var  $div = $("<div></div>",{css:{width:"100px",height:"100px",backgroundColor:"yellow"}});
document.body.appendChild($div[0]);
$(function(){console.log("one");});
$(function(){console.log("two")});	
</script>

猜你喜欢

转载自blog.csdn.net/qq_38263696/article/details/82973441