jQuery对象转化DOM对象

将jQuery对象转化成DOM对象的方法很简单,仅需将jQuery对象当作数组即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="./dist/js/jQuery.js"></script>
</head>
<body>
<div id="container">
z
</div>
<script>
//jQuery方式操作
$("#container").css('background', 'red');
//将jQuery对象转化成DOM对象之后进行操作
$("#container")[0].style.color = "red";
</script>

</body>
</html>