实例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>jQuery</title> <!--两种引入方式: <script type="text/javascript" src='http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js'></script> --> <script type="text/javascript" src=js/jquery-3.3.1.js></script> </head> <body> <ul> <li>HTML</li> <li>CSS</li> <li>JS</li> <li>jquery</li> <li>PHP</li> </ul> <h2 sytle='backgroup-color'>正在学习php.cn jquery </h2> <script type="text/javascript"> $('h2').css('color','red') $('h2').click(function(){alert("弹出信息框")}) $('li:eq(3)').css('backgroundColor','red') $('li:eq(4)').html('正在学习中') $('li')[2].style.backgroundColor = 'coral' $("<img src='https://img.php.cn/upload/avatar/000/041/989/5aa9e79cf1f4d822.jpg' width='150'>").insertAfter('li:eq(2)').css("border-radius","50%") // window.onload = function(){ alert("welcome"); } $(document).ready(function(){alert("DOM元素后")}) </script> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例