亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

JQuery事件切換

原創(chuàng) 2019-01-21 17:55:27 186
摘要:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">&

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>Document</title>

<script src="static/js/jquery-3.3.1.min.js"></script>

<style>

div{width:500px;height:500px;background: red;}

</style>

</head>

<body>

<script>

/*

    /* $(selector).hover(function () {

            // over鼠標(biāo)移上時(shí)觸發(fā)的函數(shù)

           

        }, function () {

            // out鼠標(biāo)移出時(shí)觸發(fā)的函數(shù)

        }

    );


    $("div").toggle();//如果元素是可見(jiàn)的就切換為隱藏,否則相反

    */

$(document).ready(function () {

$("div").hover(function () {

// over

$("div").css("background", "pink");

}, function () {

// out

$("div").css("background", "red");

}

);


$("button").click(function (e) {

$("div").toggle();

});

});


</script>


<div></div>

<button>點(diǎn)擊</button>

</body>

</html>


批改老師:天蓬老師批改時(shí)間:2019-01-21 17:56:31
老師總結(jié):$("div").toggle(), jQuery中的自動(dòng)切換非常有意思, 用原生來(lái)實(shí)現(xiàn)非常的麻煩, 這也是jQuery中的一個(gè)特色, 很多動(dòng)畫(huà)特效都是基于它完成的

發(fā)佈手記

熱門(mén)詞條