Blogger Information
Blog 36
fans 0
comment 1
visits 28211
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
初识JQuery
其琛的博客
Original
512 people have browsed it

代码如图

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>有关JQuery的添加方式</title>
<style type="text/css">
ul{
margin: 20px;
padding: 10px;
overflow: hidden;
list-style-type: none;
}
li{
width: 30px;
height: 30px;
margin-right: 10px;
background-color: skyblue;
float: left;
border-radius: 50%;
text-align: center;
font-weight: border;
font-size: 1.2em;
box-shadow: 2px 2px 2px #989898;

}
</style>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"> </script>
<script type="text/javascript">
// $('h2').css('color','blue')
// h2为运行已经运行jquery代码
$(document).ready(function(){
$('h2').css('color','blue')
});
// 防止文档在完全加载(就绪)之前运行 jQuery 代码
// 简写方式:
// $(function(){
//  $('h2').css('color','blue')
// });
</script>
</head>
<body>
<h2>有关JQuery</h2>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
</ul>



<!-- 有关添加JQuery的方法 -->
<!-- 第一种添加方式从Jquery.com中下载Jquery库,然后引用本地文件
<script type="text/javascript" src="../jqery/jqery-3.3.1.js"></script> -->
<!-- 第二种是网络在线从CDN中直接引用JQuery库
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.3.1/core.js"></script> -->

</body>
</html>

知识总结:

  1. 认识到了jQuery是JavaScript的一种形式

  2. jquery是为了用更少的代码做更多的东西

  3. 为了防止jQuery在内容未运行前提前运行导致失效,应把jQuery代码放入$(document).ready(function(){

    jQuery代码});

Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post