请老师指点一下
来源:2-2 编程练习
慕前端2064318
2019-07-18 18:14:49
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>点击事件</title>
<style type="text/css">
div {
float: left;
margin: 10px;
width: 100px;
height: 100px;
color: #fff;
font-size: 50px;
text-align: center;
line-height: 100px;
text-indent: -9999px;
background-color: #333;
}
</style>
</head>
<body>
<h1>添加事件处理</h1>
<div>43</div>
<div>21</div>
<div>56</div>
<div>16</div>
<div>89</div>
<div>94</div>
<div>46</div>
<div>26</div>
<div>67</div>
<div>90</div>
<div>25</div>
<div>10</div>
<div>84</div>
<div>76</div>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
<script>
//此处写代码
$('bady').click(function() {
console.log("111")
$('div')
.eq($(this).index())
.css({ textIndent: '999px' });
});
</script>
</body>
</html>
2回答
好帮手慕糖
2019-07-18
同学你好,实现效果是可以的,但是新粘贴的这个代码,缺少结束的)},如下,可以检查下是忘记写了,还是没有粘贴上来哦。
继续加油,祝学习愉快!
慕前端2064318
提问者
2019-07-18
//此处写代码
$('div').click(function() {
$('div')
.eq($(this).index() - 1)
.css({ textIndent: '1px' })
.siblings('div')
.css({ textIndent: '-9999px' });
已经可以了 请老师帮忙看一下
相似问题