溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

jquery用法

發(fā)布時(shí)間:2020-08-18 01:58:36 來(lái)源:網(wǎng)絡(luò) 閱讀:834 作者:zenge_blog 欄目:web開(kāi)發(fā)

 JavaScript 框架庫(kù) - jQuery

jQuery是JS的一個(gè)框架庫(kù),他是把很多JS語(yǔ)法實(shí)現(xiàn)的功能進(jìn)行了封裝,開(kāi)發(fā)人員可以直接調(diào)用jQuery的方法。


如何使用

要使用jQuery的某個(gè)庫(kù),必須在<script></script>標(biāo)簽中先引入該庫(kù)文件(該庫(kù)文件在jquery官網(wǎng)下載),例如:

<!DOCTYPE html>
<html>
<head><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script></head>
<body>
</body>
</html>


或者:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
 
    <title></title>
</head>
<body>
    
</body>
<script src="/static/inspinia/js/jquery-2.1.1.js"></script>
<script src="/static/inspinia/js/bootstrap.min.js"></script>
<script src="/static/inspinia/js/plugins/metisMenu/jquery.metisMenu.js"></script>


jQuery能實(shí)現(xiàn)什么功能?

我們可以通過(guò)使用 jQuery 應(yīng)用 JavaScript 效果。

jQuery 是一個(gè)“寫(xiě)的更少,但做的更多”的輕量級(jí) JavaScript 庫(kù)。

基本上,你將學(xué)習(xí)到如何選取 HTML 元素,以及如何對(duì)它們執(zhí)行類(lèi)似隱藏、移動(dòng)以及操作其內(nèi)容等任務(wù)

以下是jQuery的所有方法,

http://www.php100.com/manual/jquery/


實(shí)例:

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<title></title>
</head>

<body><p>I want to say:</p>
<input type="button" id='addId' value="追加">

</body>
<script src="js/jquery-3.1.1.js"></script>
<script src="js/jquery-3.1.1.min.js"></script>
<script type="text/javascript">
    $(function(){
        $('#addId').click(function(){
        $('p').append('alex');
        });
    })
</script>
</html>
$(function(){
    Foo();
    Bar();
})

表示web頁(yè)面一加載完后就會(huì)執(zhí)行Foo( )和Bar( )函數(shù)。


上面的例子,我們給ID=addId的標(biāo)簽綁定了一個(gè)事件(click事件),當(dāng)點(diǎn)擊“追加”按鈕時(shí),會(huì)在所有<p>標(biāo)簽的文本后面加上“alex”字符串。

測(cè)試:

打開(kāi)頁(yè)面時(shí)

jquery用法

點(diǎn)擊追加按鈕后:

jquery用法


向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI