为啥点击事件触发不了

来源:1-19 自由编程

the_shy

2019-05-01 22:15:18

<!DOCTYPE html >

<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery练习</title>

<style type="text/css">
.div1 {
	float: left;
	width: 50px;
	line-height: 30px;
	background-color: lightgray;
	margin-left: 10px;
	text-align: center;
	vertical-align: middle;
}

.div2 {
	width: 300px;
	height: 300px;
	border: solid gray 1px;
	margin-top: 60px;
	color: red;
}
</style>
</head>
<body>
	<h2>请选择背景颜色</h2>
	<div>
		<div id="blue" class="div1">蓝色</div>
		<div id="green" class="div1">绿色</div>
	</div>
	<div class="div2" id="bg"></div>
	<div>
		输入颜色首字母: <input type="text" name="color">
	</div>
	<script type="text/javascript" src="js/jquery-3.3.1.js"></script>
	<script type="text/javascript">
	alert("欢迎光临");
	$("#blue").click(function(){
		$("div.div2").css("background-color","blue");
		$("div.div2").text("蓝色背景");
	});
	
		
	</script>
</body>
</html>


写回答

1回答

the_shy

提问者

2019-05-01

老师我知道了,我的jQuery文件用的是3.4.0的版本

1

0 学习 · 9666 问题

查看课程