实例
<!DOCTYPE html> <html> <head> <title>两种引入方式</title> <meta charset="utf-8"> <style type="text/css"> .hs { float:left; list-style: none; margin: 10px; }</style> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#list > li').addClass('hs') }) // 简写: //$(function(){ //jq代码 // $('#list > li').addClass('hs') // }) </script> </head> <body> <h2>一</h2> <ul id="list"> <li>123 <ul> <li>1</li> <li>2</li> <li>3</li> </ul> </li> <li>2 <ul> <li>1</li> <li>2</li> <li>3</li> </ul> </li> </ul> </body> <!--<script type="text/javascript" src="../js/jquery-3.3.1.js"></script> <本地引用 --> <!--<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <外部引用--> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例