js和jquery操作dom的异同
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="http://code.jquery.com/jquery-1.11.3.js"></script>
<title>jquery</title>
</head>
<body>
<p id="imooc1"></p>
<p id="imooc2"></p>
</body>
</html>
<script>
window.onload = function(){
var p = document.getElementById('imooc1');
p.innerHTML = 'p1:您好!通过慕课网学习jquery才是最佳途径';
p.style.color = 'red';
}
</script>
<script type="text/javascript">
$(document).ready(function(){
var $p = $('#imooc2');
$p.html('p2:您好!通过慕课网学习jquery才是最佳的途径').css('color','blue');
});
</script>
本文标题:js和jquery操作dom的异同
本文链接:https://www.haomeiwen.com/subject/xjzlhftx.html
网友评论