ITPub博客

首页 > IT职业 > IT生活 > jquery hello world

jquery hello world

IT生活 作者:wq7210 时间:2021-09-09 10:41:13 0 删除 编辑

1 jQuery

jQuery是一个js库,一个js文件,极大地简化了编程,官网链接在这里,有compressed,uncompressed版本,使用时一样.

2 hello world

<html>
    <head>
        <title>jquery hello world</title>
        <script type="text/javascript" src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
        <script type="text/javascript">
            $(function()
            {
                $("p").html("hello world");
            });
        </script>
    </head>
    <body>
        <p></p>
    </body>
</html>

jQuery使用时直接从官网引入文件即可,这里用的是3.4.1版本.

$(function())

是

$(document).ready(function(){})

的缩写,这个函数会在DOM加载完成后执行.

$("p")

表示选择页面的所有<p>元素,html()可以设置元素的内容.
图片描述

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1830/viewspace-2825010/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 一文入门ETCD
请登录后发表评论 登录
全部评论

注册时间:2021-10-27

  • 博文量
    0
  • 访问量
    986