dom写法和jquery写法
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<script src="jquery-3.3.1.js"></script>
<script>
$(function () {
document.getElementById('btn').onclick = function () {
$('#dv').css('width', '300px').css('height', '300px').css('backgroundColor', 'yellow');
//var dvObj = document.getElementById('dv');
//var jq = $(dvObj);
//jquery对象转dom对象
//var dd = jq.get(0);
//var dd = jq[0];
//dom写法
//dvObj.style.width = '300px';
//dvObj.style.height = '300px';
//dvObj.style.backgroundColor = 'yellow';
//jquery写法-
//$(dvObj).css('width', '300px');
//$(dvObj).css('height', '300px');
//$(dvObj).css('backgroundColor', 'yellow');
//$(dvObj).text('<font color="red" size="7">hahhahah</font>')
//jquery写法二
//
//$(dvObj).css('width', '300px').css('height', '300px').css('backgroundColor', 'yellow')
// .text('<font color="red",size="7">hahhahah</font>')
};
});
</script>
</head>
<body>
<input type="button" name="name" value="display" id="btn" />
<div id="dv"></div>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<script src="jquery-3.3.1.js"></script>
<script>
$(function () {
document.getElementById('btn').onclick = function () {
$('#dv').css('width', '300px').css('height', '300px').css('backgroundColor', 'yellow');
//var dvObj = document.getElementById('dv');
//var jq = $(dvObj);
//jquery对象转dom对象
//var dd = jq.get(0);
//var dd = jq[0];
//dom写法
//dvObj.style.width = '300px';
//dvObj.style.height = '300px';
//dvObj.style.backgroundColor = 'yellow';
//jquery写法-
//$(dvObj).css('width', '300px');
//$(dvObj).css('height', '300px');
//$(dvObj).css('backgroundColor', 'yellow');
//$(dvObj).text('<font color="red" size="7">hahhahah</font>')
//jquery写法二
//
//$(dvObj).css('width', '300px').css('height', '300px').css('backgroundColor', 'yellow')
// .text('<font color="red",size="7">hahhahah</font>')
};
});
</script>
</head>
<body>
<input type="button" name="name" value="display" id="btn" />
<div id="dv"></div>
</body>
</html>