jquery hello world

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()可以设置元素的内容.
在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章