jquery事件

Original 2019-01-03 13:14:48 191
abstract:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Document</title><script type="text/javascript" src="js/jquery-3.3.1.min.js"

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

<script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>

<style type="text/css">

.box{

width: 300px;

height: 300px;

background: pink;

border-radius: 300px;

text-align: center;

line-height: 300px;

}

</style>

<script type="text/javascript">

$(document).ready(function(){

$(document).mouseover(function (aa){

$('span').text('坐标:'+aa.pageX+','+aa.pageY);

})

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

$('div').addClass('box');

$('div').mouseover(function(){

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

$(this).html("<h2>添加h2标签</h2>")

$('div h2').css({'color' :'orange','font-size': '38px'});

})


})


})


</script>


</head>

<body>

<span></span>

<div></div>

<button>点击</button>

</body>

</html>

获取元素,然后.上事件名称,要执行的事件函数代码块!

Release Notes

Popular Entries