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

jQuery事件切換

asal 2019-01-27 13:45:59 232
abstrak:<!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">

<script type="text/javascript"src="https://code.jquery.com/jquery-3.1.1.min.js"></script>

<title>jQuery事件切換</title>

<style type="text/css">

    div,p{width: 200px;height: 200px;border: 1px solid #ccc;}

  </style>

</head>

<body>

<script type="text/javascript">

// hover(over,out)

// over:鼠標(biāo)移上元素上要觸發(fā)的一個(gè)函數(shù)

// out:鼠標(biāo)移出元素上要觸發(fā)的一個(gè)函數(shù)

$(document).ready(function(){

//  $('div').hover(

//       function(){

//       $(this).css('background','red')

//       },

//       function(){

//        $(this).css('color','#fff')

//       }

//    )

// toggle() 如果元素是可見的,就切換為隱藏,否則相反

$('button').click(function(){

  $('p').toggle().css('background','red')

})


})



</script>

<div>我是內(nèi)容</div>

<p style="display: none;"></p>

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

</body>

</html>


Guru membetulkan:天蓬老師Masa pembetulan:2019-01-27 14:05:07
Rumusan guru:$('p').toggle().css('background','red'), 如果這行代碼不用jquery , 想過應(yīng)該怎么寫嗎?

Nota Keluaran

Penyertaan Popular